I think the thread title described the issue well enough, but just in case: ALL of my songs are happy to play individually, but when I try to switch songs by calling MediaPlayer.Stop(); followed by MediaPlayer.Play(someDifferentSong);, the song I just stopped starts over again from the beginning - the new song is not played until after the first song stops playing!
I’ve tried googling around, but mostly all I could find were people who had trouble getting songs to play AT ALL; I wasn’t able to find anyone else with my particular issue.
I’m developing on Windows 7, using MonoGame 3.2 DirectX.
here’s my song-playing code; it’s pretty simple. I worry I’m just making some stupid, simple mistake. thanks for any help!
private Song[] _songs; // these get loaded using Content.Load<Song>(...)
private int _current_song_index = -1;
public void PlaySong(int song)
{
// I've tried adding in Console.WriteLine(...)s to confirm that the passed in song variable is different from the _current_song_index, within _songs.Length, etc, and all of that seems to be OK.
if (song != _current_song_index)
{
if (_current_song_index != -1)
MediaPlayer.Stop();
if(song >= 0 && _songs[song] != null)
{
MediaPlayer.IsRepeating = true; // I tried taking this out, just in case; didn't change anything
MediaPlayer.Play(_songs[song]);
}
_current_song_index = song;
}
}