Search code examples
androidiosxamarinxamarin.formsmedia-player

Is there a Xamarin.Form MediaPlayer that works for both iOS and Android?


I think we can use Android.Media.MediaPlayer Class and MPMoviePlayerController Class (Xamarin.iOS.dll) to play back stream videos on Android and iOS device, but they are all platform specific controls. Is there any platform-independent control we could use to play stream video for Android and iOS in Xamarin.Form app? I hope I can use it once and for all these two mobile platforms and hope it is not a web-view control. Thanks.


Solution

  • I'd personally use LibVLCSharp which is cross-platform audio and video API for the .NET platforms. It supports streaming, equalizers, subtitles, network browsing, and many other things, so it's quite future-proof in case you want to extend the feature set of your application.

    As per your requirement, the library includes a control that you can place right into XAML, like this:

     <vlc:VideoView x:Name="videoView" MediaPlayer="{Binding MediaPlayer}" AbsoluteLayout.LayoutBounds="0,0,1,1" AbsoluteLayout.LayoutFlags="All" InputTransparent="True"/>
    

    Here's an official Xamarin.Forms sample that should get you started: https://github.com/videolan/libvlcsharp/tree/master/Samples/Forms