Forum Xamarin.Android

I am having problem setting up SetOnCompletionListener on MediaPlayer - Android

AdnanKhanAdnanKhan USMember ✭✭

I am having problem setting up SetOnCompletionListener on MediaPlayer.
This onCompletion method is never get's called.

on top i have this declare

using Android.Media;

protected MediaPlayer player;
protected MediaPlayer.IOnCompletionListener _OnCompletionListener; //( is this how i do this?)

In click function i have this -- is this how i set onCompletionListener when MediaPlayer finishes.
player.SetDataSource(filePath); //Enter initialized state.
player.Prepare(); // Enter Preparing and Prepared state.
player.SeekTo(Convert.ToInt32(_mypos));
player.SetOnCompletionListener(_OnCompletionListener); //(is this correct)
player.Start(); // Enter started state.

//(below function never get called)
public void onCompletion(MediaPlayer mp){
Console.WriteLine("Called on Completion");
}

Please Help. Thank You.

Posts

  • AdnanKhanAdnanKhan USMember ✭✭

    Thank You it worked. :)

Sign In or Register to comment.