Play music and soundsTo make this working you have first to add a music file (I have called it "file.mp3") to your content folder via the MonoGame Pipeline. After you have done this, add following line to your class where you want to use the music/sounds:
using Microsoft.Xna.Framework.Media;
Then you have to load the song:
Add following:
To your fields/properties:
and
To the LoadContent method:
song = content.Load<Song>("file");
To specify if you want to loop the music, you have to add
MediaPlayer.IsRepeating = true;
Now you can start playing your music in the Update() or Draw() method with following code:
if (IsPlaying == false)
{
MediaPlayer.Play(song);
IsPlaying = true;
}
To pause the music add
To resume add
And to stop playing add