Using Songs

Was trying to find a way of playing song after song, or selecting them from a list etc, couldn’t find exactly what i needed so i wrote this, all the songs are oog format, hope it helps someone

  public class AudioClass
  {
    private List<Song> songList;
    public List<SoundEffect> sfxList;
    private int songIndex = 0;
    public float musicVolume = 0.5f;

    // How to make an instance of a sound effect
    //      var instance = sfxList[0].CreateInstance();
    //      instance.IsLooped = true;
    //      instance.Play();



    #region Audio Constructor
    /*********************************************************************************************
     * Function Name : Audio Constructor
     * Description : do any initialization for the audio
     * ******************************************************************************************/
    public AudioClass()
    {
      sfxList = new List<SoundEffect>();
      songList = new List<Song>();
      songList.Add(Game1.sContent.Load<Song>(assetName: @"Soundfx\pnp1"));                // load a song
      songList.Add(Game1.sContent.Load<Song>(assetName: @"Soundfx\pnp2"));                // load a song
      songList.Add(Game1.sContent.Load<Song>(assetName: @"Soundfx\pnp3"));                // load a song
      sfxList.Add(Game1.sContent.Load<SoundEffect>(assetName: @"Soundfx\balldrop"));      // load a soundfx
      MediaPlayer.Volume = musicVolume;
      songIndex = 0;
      MediaPlayer.Play(songList[songIndex]);
      MediaPlayer.MediaStateChanged += MediaPlayer_MediaStateChanged;
    }
    private void MediaPlayer_MediaStateChanged(object sender, EventArgs e)
    {
      songIndex += 1;
      if (songIndex >= songList.Count) songIndex = 0;
      MediaPlayer.Play(songList[songIndex]);
    }
    #endregion

    ~AudioClass()
    {
      songList.Clear();
      sfxList.Clear();
    }
  }
  public enum eSFXList
  {
    balldrop = 0,
  }
}

Did you try SongCollection and MediaPlayer.Play(SongCollection)?

Many times, read sooooooo many items on how to play a single song but as yet not a single example using SongCollection, if you have an example please show me, i’ll gladly use it

Hi. It doesn’t work for me, MediaPlayer.MediaStateChanged += MediaPlayer_MediaPlayerStateChanged I coded this at the protected override void LoadContent()
{
_spriteBatch = new SpriteBatch(GraphicsDevice);
this.Song = Content.Load(“Peaceful Place”);
MediaPlayer.Play(Song);
MediaPlayer.MediaStateChanged += MediaPlayer_StateChanged;
Please help. thank you. I am trying to make an audio game for blind gamers.