-
Multimedia and MP3
Hi
Is there anyway of knowing when a multimedia device finishes playing. At the moment I am making an MP3 player and I want to know when the current file which is playing finishes playing so that I can go to the next file in the playlist.
I am using the mcisendstring command to play the MP3 file. The notify flag does not work.
Thanks in advance
Appi
-
Just get the current mpeg position of playing:
Code:
Public Function GetCurrentMPEGPos() As Long
Dim dwReturn As Long
Dim pos As String * 255
dwReturn = mciSendString("status mpeg position", pos, 255, 0&)
If Not dwReturn = 0 Then 'not success
GetCurrentMPEGPos = -1
Exit Function
End If
GetCurrentMPEGPos = Val(pos)
End Function
And the total length (in Milliseconds)
Code:
Public Function GetTotalTimeByMS() As Long
Dim dwReturn As Long
Dim TotalTime As String * 255
dwReturn = mciSendString("set mpeg time format ms", Total, 255, 0&)
dwReturn = mciSendString("status mpeg length", TotalTime, 255, 0&)
mciSendString "set mpeg time format frames", Total, 255, 0& ' return focus to frames not to time
If Not dwReturn = 0 Then 'not success
GetTotalTimeByMS = -1
Exit Function
End If
GetTotalTimeByMS = Val(TotalTime)
End Function
And if GetCurrentMPEGPos >= GetTotalTimeByMS then MP3 Finished. :) Make sense?