Skip to main content
gamedev.net
🔒 Locked

how does Play(...) work???

Started by andyborowicz 1 reply 500+ views
Original Post
andyborowicz
andyborowicz
I am a beginner in DirectX so I'd be grateful for patience and help, thank you :) Could anyone explain to me how does Play work on a single buffer? I loaded a wav file into my buffer and this command works very well. But when I want to play it multiple times...? Why doesn't it work when I write it two times in a row? DSBuffer->Play( 0, 0, NULL); DSBuffer->Play( 0, 0, NULL); It just plays the sound once. Of course neither worked SetCurrentPosition between them. I know that I can put looping instead of NULL - but it won't play my file two times, but until I stop it myself. And changing the buffer parameters is then totally impossible. I also tried to loop with 'while' or 'for' but with no (or random, single) results. May somebody make it clear, please?
Aardvajk
Aardvajk
Play will not restart the sound if it is currently playing when it is called. The calls are asynchronous to the actual sound being played. You need to stop it first then play it again I think, or wait until it has finished somehow before you call play again.
Evil Steve
Evil Steve
You need to set the play position to the start of the file again before you play the second time.

The first play will play, and read through to the end. Now the read cursor is at the end of the file, so the next play will end immediately.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.