Hey guys,
I have a Xamarin.Forms app with an Android PageRenderer used to stream a m3u8 video. The renderer displays the video (after a small delay for buffering) as expected. The issue I'm running into is both the navigation bar back button and the hardware back button aren't working as expected. The navigation stack gets popped back because the page title changes but the video does not dismiss. I have my page renderer below as well as a sample project demonstrating the issue. Any help would be greatly appreciated.
Thanks
[assembly:ExportRenderer(typeof(PlayVideoPage), typeof(VideoRenderer))]
namespace VideoView.Sample.Droid
{
public class VideoRenderer : PageRenderer
{
private Activity activity;
private Android.Widget.VideoView videoView;
protected override void OnElementChanged(ElementChangedEventArgs<Page> e)
{
base.OnElementChanged(e);
if (e.OldElement != null || Element == null)
{
return;
}
activity = Context as Activity;
activity.SetContentView(Resource.Layout.VideoPlayer);
videoView = activity.FindViewById<Android.Widget.VideoView>(Resource.Id.videoPlayer_vwVideo);
videoView.SetVideoURI(Android.Net.Uri.Parse("http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"));
videoView.SetMediaController(new MediaController(Context));
videoView.RequestFocus();
videoView.Prepared += (sender, preparedE) => videoView.Start();
}
protected override void OnVisibilityChanged(Android.Views.View changedView, ViewStates visibility)
{
if(visibility == ViewStates.Gone)
{
videoView.StopPlayback();
videoView.Dispose();
}
}
}
}