Is there any way for a program to know when it has reached the end of an audio file (with no picture frames)?
Jason
reaching the end of a music file
- Rook Zimbabwe
- Addict
- Posts: 4322
- Joined: Tue Jan 02, 2007 8:16 pm
- Location: Cypress TX
- Contact:
Re:
> if you know the exact playtime of you track then just count it on your own
Interesting. Does anyone know how to tell the play length of an MP3 file?
Interesting. Does anyone know how to tell the play length of an MP3 file?
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
Re: reaching the end of a music file
@PB: I`ver tried several mp3-Files and MovieStatus seems to work now -> returns 0, when the song has ended...tried about 20 mp3-Files...from 2min up to 10min...Can you upload one, where it doesn`t work?
PureBasic for Windows
Re: reaching the end of a music file
@Marco2007: Actually, you're right, it's working for me now. 
Maybe I coded something wrong before, because I was definitely
not getting a correct result with my last attempt. Thanks!

Maybe I coded something wrong before, because I was definitely
not getting a correct result with my last attempt. Thanks!

I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
Re: reaching the end of a music file
Are you sure it works?
I had some problems earlier on when I played with the examples.
Uncomment the delay and this works for me, but not without some startup-delay.
I had some problems earlier on when I played with the examples.
Uncomment the delay and this works for me, but not without some startup-delay.
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
The best preparation for tomorrow is doing your best today.
Re: reaching the end of a music file
KJ67, I see what you mean. Here's my workaround for you.
It plays the MP3 until it finishes or you close the window.
Note the While/Wend instead of Delay(500) -- it's faster.
It plays the MP3 until it finishes or you close the window.
Note the While/Wend instead of Delay(500) -- it's faster.
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
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
Re: reaching the end of a music file
load file names into a list and then you can process through them like this
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