开发者

How to detect that sound has ended in the XNA MediaPlayer?

I know how to use MediaPlayer.Play(song); to start playing some song/effec开发者_JS百科t.

But how to detect that song/effect ended playing?


You may want to try implementing these two events:

http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.media.mediaplayer.activesongchanged.aspx

and

http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.media.mediaplayer.mediastatechanged.aspx

An alternate way would be to keep a MediaState variable called "previousState" or whatever, and each Update(), check the previous state for Stopped or Paused, and run whatever code you want in that if. Of course, afterward, update the previous by doing:

previousState = MediaPlayer.State;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜