Media player crashes app on back button

I have the following code to initiate my my media player which plays my annimated logo;
ISurfaceHolder holder = VideoView_Logo.Holder;
holder.AddCallback(this);
var descriptor = Assets.OpenFd("a.3gp");
mediaPlayer = new MediaPlayer();
mediaPlayer.SetDataSource(descriptor.FileDescriptor, descriptor.StartOffset, descriptor.Length);
mediaPlayer.Prepare();
mediaPlayer.Looping = true;
mediaPlayer.Start();
This works fine when i enter the screen. However, when i leave the screen and try and go back, my app crashes with the following error;

Java.IO.IOException: Prepare failed.: status=0x1

Please help.

Regards

Best Answer

Answers

  • farhaadadamfarhaadadam ZAMember

    Thanks for the quick response. I cleaned the solution, then rebuilt and followed your advice;
    mediaPlayer.Stop();
    mediaPlayer.Release();
    mediaPlayer.Dispose();
    Worked like a charm!!!

Sign In or Register to comment.