Languages

Menu
Sites
Language
TV Video player

I'd like to play back a video stream (http/dlna/rtsp etc). Which control in Xamarin.Forms do I need to use?

May I suggest the TV Sample apps also contains a video player? It seems like quite an oversight, considering it's a TV, and will probably be one of the most common scenarios for TV Apps..

Responses

8 Replies
John Ixion

agreed, VisioForge would be great, for instance

 

https://www.visioforge.com/media-player-sdk-net.html

John Ixion

.NET control that hosts the audio/video capabilities of the VLC libraries

 

https://github.com/ZeBobo5/Vlc.DotNet

Ahmad ElMadi

There is a control in Tizen called Player And I suppose this is one we need to use for video playback , however the problem is that how do we use in the Portable project. The only way to do so (at this point) is to use custom renderers. However, the problem is that custom renderers are not supported (at this point and at least with me) 

What Olver Nyssen posted about VLC and the other player are for Windows Froms and windows WPF , but not for Xamarin.Forms 

Stéphane Mitermite

I finally succedded in playing a video with this code :
var player = new Player();
player.Display = new Display(Forms.Context.MainWindow);
player.SetSource(new MediaUriSource(uri));
await player.PrepareAsync();
player.Start();

 

Stéphane Mitermite

(with internet privilege added in tizen-manifest.xml)

Ahmad ElMadi

How did  you bring that code up to the shared project ?  Isuppose you are using Xamarin.Forms , right ? 

Stéphane Mitermite

Yes, I'm using Xamarin.Forms. This code is Tizen specific, it can't be in your Xamarin.Forms shared project. For example, you can add an interface in your Xamarin.Forms shared project :
public interface IPlayer
{
    Task Start(string uri);
 }

In your Tizen projects (in a Tizen class library for example), add the following class :
public class MyPlayer : IPlayer
{
        public async Task Start(string uri)
        {
            var source = new MediaUriSource(uri);
            var player = new Player();
            player.Display = new Display(Forms.Context.MainWindow);
            player.SetSource(source);
            await player.PrepareAsync();
            player.Start();
        }
}

So, you can pass this IPlayer implementation to your App class and you will be able to play a video in your app  :
LoadApplication(new App(new MyPlayer()));

John Ixion

Thanks, Stéphane !

There is also a MediaManager Plugin for Xamarin:

https://blog.xamarin.com/play-audio-and-video-with-the-mediamanager-plugin-for-xamarin/