reaching the end of a music file
Posted: Sat Apr 19, 2008 7:48 pm
Is there any way for a program to know when it has reached the end of an audio file (with no picture frames)?
Jason
Jason
http://www.purebasic.com
https://www.purebasic.fr/english/
This might have to be done from the API in windows...Note: Be careful with this function when using sounds (e.g. MP3) as no pictures (frames) exist.
Code: Select all
If InitMovie() = 0
MessageRequester("Error", "Can't initialize movie playback !", 0)
End
EndIf
MovieName$ = OpenFileRequester("Choose the movie to play", "", "Movie/Audio files|*.avi;*.mpg;*.asf;*.mp3;*.wav|All Files|*.*", 0)
If MovieName$
If LoadMovie(0, MovieName$)
OpenWindow(0, 100, 150, MovieWidth(0), MovieHeight(0), "PureBasic - Movie")
PlayMovie(0, WindowID(0))
;Delay(500)
Repeat
If MovieStatus(0)=0
MessageRequester("Done?","")
End
EndIf
Until WaitWindowEvent() = #PB_Event_CloseWindow
Else
MessageRequester("Error", "Can't load the movie...", 0)
EndIf
EndIf
Code: Select all
m$="D:\[Media]\Music\Darryl McDowell - Soul Glo.mp3"
If OpenWindow(0,200,200,200,100,"test",#PB_Window_SystemMenu)
TextGadget(0,10,10,100,20,"")
InitMovie() : LoadMovie(0,m$) : PlayMovie(0,WindowID(0))
While MovieStatus(0)=0 : Wend ; Let the movie start! :)
Repeat
s=MovieStatus(0) : SetGadgetText(0,Str(s))
Until s=0 Or WaitWindowEvent(1)=#PB_Event_CloseWindow
EndIf
Code: Select all
If Not IsMovie(0)
If Not NextElement(queue())
FirstElement(queue())
EndIf
If LoadMovie(0,queue())
PlayMovie(0,hwnd)
Delay(100) ;need a delay or movie status may return not playing
;or like pb said a while loop
;while not moviestatus(0)
; delay(0) ;let the cpu context change nicely
;wend
Else
DeleteElement(queue())
EndIf
ElseIf Not MovieStatus(0)
DeleteElement(queue())
FreeMovie(0)
EndIf