Sign in to follow this  
Crazy Jonny

Detecting the position and end of a sound

Recommended Posts

Crazy Jonny    122
How do you detect when a sound has ended, and detect and set the position where it currently is? I have several tracks of background music for a game, and one track of menu music. I need to be able to pause it, record the position of the background track, e.g. 1 minute 13 seconds into the track, and when I unpause, to make the sound start playing again from the same point it stopped at. Also, when a track has ended, I need to be able to detect that it has ended, so I can play a different track.

Share this post


Link to post
Share on other sites
Are you using DirectSound or DirectMusic/Audio?

In DirectSound, the "IDirectSoundBuffer8" interface has the methods: GetCurrentPosition(), SetCurrentPosition(), and GetStatus(). You can get the details of the parameters from the DirectX SDK Docs or MSDN.

In DirectMusic/Audio 'IDirectMusicSegment8' and 'IDirectMusicSegmentState' have a TON of methods for accessing and setting positions and automatic loop points, and the "IDirectMusicPerformance8" interface has even more for determining the current playing state of the segements. If would be ridiculous for me to try to list all the details here, so, as before, check it out in MSDN. Or, if you still have the DirectX 8 Docs, you can find it in there.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this