0
votes

I'm building an app with Xamarin Forms that incorporates a live stream. I'm using the FormsVideoLibrary specified here:

https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/custom-renderer/video-player/

When the live stream is active, the stream plays fine and I have no issues. However, when the live stream isn't active, I get an annoying "Can't play this video" display alert only on android devices. Is there a way I can hide this alert or catch the error that's thrown when the live stream isn't active?

1

1 Answers

0
votes

try to add the SetOnErrorListener in your VideoPlayerRenderer and overwire the OnError method,let it return true;

like :

 class VideoPlayerRenderer : ViewRenderer<VideoPlayer, Android.Widget.RelativeLayout>,MediaPlayer.IOnErrorListener
 {

    protected override void OnElementChanged(ElementChangedEventArgs<VideoPlayer> e)
    {
         ....
         videoView.SetOnErrorListener(this);
    }

    public bool OnError(MediaPlayer mp, [GeneratedEnum] MediaError what, int extra)
    {
        return true;
    }
 }