Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Play m3u8 stream in Android Renderer

$
0
0

Hey guys,

I'm making a Xamarin.Forms app that will stream video from a m3u8 feed. I've created a custom renderer in iOS and everything is working as expected there. I'm having some issues with Android. I've tried a few different implementations but I get the same result: a black screen with video player controls. The video appears to start playing, but I do not get any sound or images. If I fast forward the player locks up and I get an alert that says the video could not be played. I've hooked into the error event on VideoView but most of it's properties are null or random numbers (like -38 for message). I have my renderer code pasted below, any help or insight would be greatly appreciated.

[assembly:ExportRenderer(typeof(VideoPlayerPage), typeof(VideoPlayerRenderer))]
namespace MobileViewer.Droid.Features.Video
{
    public class VideoPlayerRenderer : PageRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<Page> e)
        {
            base.OnElementChanged(e);

            var activity = Context as Activity;
            activity.SetContentView(Resource.Layout.VideoPlayer);

            VideoView videoview = activity.FindViewById<VideoView>(Resource.Id.videoPlayer_vwVideo);
            videoview.SetVideoURI(Android.Net.Uri.Parse("http://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/sl.m3u8"));
            videoview.SetMediaController(new MediaController(Context));
            videoview.RequestFocus();

            videoview.Prepared += (sender, preparedE) => videoview.Start();
        }
    }
}

Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>