I have a MediaPlayer
public MediaPlayer backgroundMusicPlayer = new MediaPlayer ();
Now, because its background music, I'd like to repeat the song after its over.
How should I implement this?
This is what I found:
An event is raised when the song ends: backgroundMusicPlayer.MediaEnded
I am not sure what I should do about this? I am new to C# and programming in general.
EDIT:
public void PlaybackMusic ( )
{
if ( backgroundMusicFilePath != null )
{
backgroundMusicPlayer.Open (new Uri (backgroundMusicFilePath));
backgroundMusicPlayer.MediaEnded += new EventHandler (Media_Ended);
backgroundMusicPlayer.Play ();
return;
}
}
private void Media_Ended ( object sender, EventArgs e )
{
backgroundMusicPlayer.Open (new Uri (backgroundMusicFilePath));
backgroundMusicPlayer.Play ();
}
This works, but I need to open the file every time. Is this the only way?