RE:MP3 files EJEMPLO!
Publicado por
Ernesto (1 intervención) el 29/03/2009 17:04:32
Probé lo que me dijiste.. y me salió esto:
Private Function LoadMP3(ByVal FileName As String, ByVal looping As LoopStyle) As Long
If Not FileExist(App.Path & "MP3" & FileName, vbArchive) Then Debug.Print "El archivo:"; FileName & " no existe.": Exit Function
If LastMP3 = 0 Then
LastMP3 = 1
Else
LastMP3 = LastMP3 + 1
End If
ReDim Preserve DSBuffers(0 To LastMP3) As SoundBuffer
Dim i As Integer
For i = 1 To UBound(DSBuffers)
With DSBuffers(i)
If .FileName = vbNullString Then
.FileName = FileName
.looping = looping
LoadMP3 = i
Exit For
End If
End With
Next i
End Function
Public Function PlayMP3(ByVal FileName As String, Optional ByVal srcX As Byte = 0, Optional ByVal srcY As Byte = 0, Optional ByVal LoopSound As LoopStyle) As Long
Dim bufferIndex As Integer
'Get the buffer index were wave was loaded
bufferIndex = LoadMP3(FileName, LoopSound)
If bufferIndex <> 0 Then
If DSBuffers(bufferIndex).FileName <> vbNullString Then
DSBuffers(bufferIndex).x = srcX
DSBuffers(bufferIndex).y = srcY
FileName = Trim(Left$(String$(165, 0), GetShortPathName(App.Path & "MP3" & DSBuffers(bufferIndex).FileName, String$(165, 0), 164)))
Call mciSendString("Open " & FileName & " Alias audio" & CStr(bufferIndex), 0&, 0, 0)
Call mciSendString("play audio" & CStr(bufferIndex), 0&, 0, 0)
If srcX <> 0 And srcY <> 0 Then
' Call Update3DSound(bufferIndex, 0, 0)
End If
'Esto deberia ser cuando termina el mp3 de sonar..
LastMP3 = LastMP3 - 1
ReDim Preserve DSBuffers(0 To LastMP3) As SoundBuffer
End If
End If
End Function
y no me funciona.. si te fijas esta parte:
'Esto deberia ser cuando termina el mp3 de sonar..
LastMP3 = LastMP3 - 1
ReDim Preserve DSBuffers(0 To LastMP3) As SoundBuffer
vuelvo a redimensionar el array.. pero eso está mal..
alguna solución?