I'm making a game with XNA and trying to get some background music to loop correctly. Because the file is an MP3 of about 30 seconds in length, I instantiated it as a Song. I want it to loop perfectly, but even when I set the MediaPlayer.IsRepeating property to true, there is always a delay of about one second before the song starts up again. Is there any way to eliminate this delay such that the song loops instantly, so it can play more fluently?


2 Answers 2


The MediaPlayer in XNA has always had a short delay when looping songs and I haven't seen any way to resolve the issue. What is your target platform? You could consider using XACT if you are targeting the Xbox or Windows as it doesn't have the same issues as the MediaPlayer API.

I'd recommend against using SoundEffect (as recommended by Sprunth) to play background music if you are going to release on XBLIG or the WP7 marketplace as that doesn't mesh well with the built in media player and leads to certification/peer review issues. For example, if you play your background music as a SoundEffect on the Xbox and a player wants to use their own custom soundtrack your music will still keep playing over top, whereas if you had used a Song as recommended it would "magically" stop. Similar bad things happen on the phone.

  • 4
    \$\begingroup\$ Thanks for clarifying why Song is the proper choice here. \$\endgroup\$ Nov 28, 2011 at 16:34
  • \$\begingroup\$ +1 For XACT. You should be importing your music and sound effects as uncompressed WAV files and allowing XACT to compress them and pack them into wavebanks. \$\endgroup\$ Nov 29, 2011 at 1:40

I made a quick xna app with a ~15 second mp3 and can confirm that MediaPlayer does have this issue when looping. I tried it again with SoundEffect (and SoundEffectInstance for looping in XNA4) and the issue disappeared. So I guess you could switch to SoundEffect?

Some research/sources: Looping music using MediaPlayer problem Ways of fixing the delay gap when looping MP3s in XNA 3.0


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .