3
votes

I'm developing a simple rhythm game for Windows Phone 7 using XNA. Currently I'm writing the tombstoning logic but I've stumbled with the audio state.

I have a song playing in the background, using MediaPlayer. When my game is tombstoned, song playback should stop and its state saved, so that when my game is loaded again the song starts playing where it was left. I'm using the MediaPlayer class to play the song, but it seems there's no way to seek the song to an arbitrary position.

Is there any way to save and restore the state of MediaPlayer so that the song playback can be properly resumed? Or is there a better way to play a song in order to support tombstoning?

Thanks in advance

2
have you tried Pause() and Resume()?Adam

2 Answers

0
votes

Try setting mediaplayer.position which is the point in the song where you want to play from.

http://msdn.microsoft.com/en-us/library/system.windows.media.mediaplayer.position.aspx

0
votes

It seems like the solution provided by dolhaig on CodeProject should give you what you need. Seems to be able to handle the saving off and resuming the song at it's current state and he indicates that it supports XNA in the article.

http://www.codeproject.com/KB/windows-phone-7/ResumeMusicPlayback.aspx?msg=3859350