This project is read-only.

Sound - Song Playlist

Oct 9, 2010 at 5:26 PM

Am implementing a playlist of songs in my game that loops in the background. Everything works fine except that MediaPlayer.State is not implemented so I have no way of knowing when the song has completed and need to move to the next song.

In XNA windows I simply check to see if the song is not playing

if (MediaPlayer.State != MediaState.Playing)

in the Update loop and then start the next song. Is there a workaround for this or can I have only one song that loops.


Oct 25, 2010 at 7:41 PM
Edited Oct 25, 2010 at 7:41 PM

You could do it the hardway :) convert fps to seconds, see how many seconds the song have and then just second after second... like this

after 1 second

int Song1Timer = 360 // in case the song has 6 minutes




it's not a flexible solution but i think it might work quite well


Oct 25, 2010 at 7:57 PM

Thanks for the reply. I had thought of something like that but it is part of a much bigger problem.

How does one communicate with silverlight environment from the game code?

Can one know if music is currently being played in the browser? Overlapping music sounds terrible and is not a pleasant user experience until he gets it turned off in the game. I would also like to know the browser characteristics to change game options like size of window and maybe even other user preferences. I was thinking of making my game skinable.  Maybe I'm just dreaming about these things.

Best wishes,