I want to play the next song after the current song had finished. The next song can be the same song again or a different song. On Android everything works fine but on iOS I don’t hear anything when the second song starts. I have tested it many times on my iPad Air and I don’t get an error message.
I use Monogame.Framework.iOS(3.8.0.1641) nugget package.
Why does XnaMediaPlayer not play the next song?
Starting the song for the first time when I start my game:
XnaMediaPlayer.Stop();
XnaMediaPlayer.IsRepeating = false;
XnaMediaPlayer.Play(Song1, new TimeSpan(0, 0, 0));
Play the second song after the first had finished:
TimeSpan CurrentPosition = XnaMediaPlayer.PlayPosition;
TimeSpan Offset = new TimeSpan(0, 0, 0, 0, 500);
TimeSpan SongDuration = Song1.Duration;
TimeSpan Limit = CurrentPosition + Offset;
if (Limit >= SongDuration)
{
XnaMediaPlayer.Stop();
XnaMediaPlayer.IsRepeating = false;
XnaMediaPlayer.Play(Song1);
}