Page 1 of 1
Using GetStatus() with a PB loaded sound?
Posted: Fri Dec 03, 2004 6:37 pm
by matthew180
Greetings,
Can anyone tell me how I can access the directX sound functions on a sound loaded with PB LoadSound()? I'd really like to know when a sound has finished playing, and DirectSound provides a GetStatus function for each buffer that will, amoung other things, tell you if the sound is still playing.
It sure would be nice if Fred could add a SoundStatus function (poke poke), but until then is there a way to access that GetStatus function on a PB loaded sound?
Thanks,
Matthew
Re: Using GetStatus() with a PB loaded sound?
Posted: Fri Dec 03, 2004 7:42 pm
by traumatic
I don't know about the sound commands but it may be possible with
the movie commands.
Just to get you an idea:
Code: Select all
Structure MovieStruc
Movie.IGraphBuilder
MediaControl.IMediaControl
MediaEvent.IMediaEventEx
Window.IVideoWindow
Audio.IBasicAudio
Video.IBasicVideo
MediaSeeking.IMediaSeeking
State.l
EndStructure
InitMovie()
*movie.MovieStruc = LoadMovie(0, "D:\WINDOWS\Media\chimes.wav")
*movie\MediaSeeking\GetDuration(@duration.l) ; determine the duration - not necessary here ;)
Debug "Duration: "+Str(duration)
PlayMovie(0, 0)
Repeat
*movie\MediaEvent\WaitForCompletion(10, @evCode.l)
Delay(2)
Until evCode = 1
StopMovie()
MessageRequester("", "done!")
End
WaitForCompletion() sets evCode.l to 1, if the FilterGraph finished
rendering all available data. Maybe this helps you.
I can't see any way to access the IDirectSoundBuffer though (in this case,
PlayMovie() uses DirectShow of course)
BTW: Fred, please try this:
Code: Select all
Debug *movie\MediaEvent\WaitForCompletion(10, @evCode.l)
I get an "PUSH - invalid operand" error.
Posted: Fri Dec 03, 2004 8:44 pm
by matthew180
Very nice! I will certinaly give it a try and post my results here. Thanks for the example!
Matthew
Posted: Sat Dec 04, 2004 1:36 am
by traumatic
I spent some more time thinking about it and while I don't know what you're up to,
maybe this approach suits you better:
Code: Select all
*movie\MediaEvent\GetEvent(@evCode.l, @param1.l, @param2.l, 0)
If evCode = #EC_COMPLETE
Debug "done playing"
EndIf
*movie\MediaEvent\FreeEventParams(evCode, param1, param2)
(#EC_COMPLETE = $01)
...of course you'd normally check the return-value, ie...
Code: Select all
If *movie\MediaEvent\GetEvent(@evCode.l, @param1.l, @param2.l, 0) = #S_OK
If evCode = #EC_COMPLETE
Debug "done playing"
EndIf
*movie\MediaEvent\FreeEventParams(evCode, param1, param2)
EndIf
...but that raises the already mentioned "invalid-operand" error...
Well, I only wanted to give you an idea anyway

Posted: Wed Feb 16, 2005 10:47 pm
by traumatic
Just checked the above code with 3.93b1...
...the bug seems to be fixed now

Posted: Wed Feb 16, 2005 11:34 pm
by dracflamloc
Can PlayMovie be used to play any type of audio that the user has a codec installed for?
Posted: Thu Feb 17, 2005 12:05 am
by traumatic
As PlayMovie() utilizes DirectShow, I'd say yes.
Posted: Thu Feb 17, 2005 12:46 am
by dracflamloc
nm, i just tested and i'm pretty sure it can. Too bad it takes up so much ram using the Movie functions though =(
But between the bugs of audiere and MP3 bitrates and a few extra megs of ram, it'll have to be the ram for now in DracMP3.