TLDR
TLDR

Reputation: 1278

What video or media player should I use with Xamarin.Forms? 3 seem available

I'm trying to figure out which video player is the most generally purpose supported by Microsoft, as Xamarin seems to have two (perhaps not including the iOS native one?), and Azure has this one

My intention is to pass this player a playlist, and have the user add and edit that list, or those lists.

A key iOS and Android feature I need is to play music (or audio-only from the video stream). I don't want to waste battery power and want a screen lock in case I accidentally bump the screen, my RSA or Ted Talk would stop.

Or music video playlist, but I'm only looking at the audio.

Upvotes: 0

Views: 2336

Answers (1)

Cherry Bu - MSFT
Cherry Bu - MSFT

Reputation: 10346

According to your description, you want to pass playlist to mediaplayer and let user add and edit this list.

I suggest you can take a look Plugin.MediaManager.Forms in Xamarin.Forms.

Firstly, you need to make sure to call Init() in all the native platforms on startup of your app.

For example, adding the following code in MainActivity.OnCreate method.

CrossMediaManager.Current.Init(this);

Secondly, pass list that contains media or video to MediaManager, user can add and edit item in list

<ContentPage
x:Class="FormsSample.mediaplayer.Page1"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:forms="clr-namespace:MediaManager.Forms;assembly=MediaManager.Forms">
<ContentPage.Content>
    <StackLayout>
        <Button
            x:Name="btn1"
            Clicked="btn1_Clicked"
            Text="open media" />
        <forms:VideoView HeightRequest="202" WidthRequest="202" />
    </StackLayout>
</ContentPage.Content>
 public partial class Page1 : ContentPage
{
    public IList<string> Mp3UrlList => new[]{
"https://ia800806.us.archive.org/15/items/Mp3Playlist_555/AaronNeville-CrazyLove.mp3",
"https://ia800605.us.archive.org/32/items/Mp3Playlist_555/CelineDion-IfICould.mp3",
"https://ia800605.us.archive.org/32/items/Mp3Playlist_555/Daughtry-Homeacoustic.mp3",
"https://storage.googleapis.com/uamp/The_Kyoto_Connection_-_Wake_Up/01_-_Intro_-_The_Way_Of_Waking_Up_feat_Alan_Watts.mp3",
"https://aphid.fireside.fm/d/1437767933/02d84890-e58d-43eb-ab4c-26bcc8524289/d9b38b7f-5ede-4ca7-a5d6-a18d5605aba1.mp3"
};

    public Page1()
    {
        InitializeComponent();          
    }

    private async void btn1_Clicked(object sender, EventArgs e)
    {
        await CrossMediaManager.Current.Play(Mp3UrlList);
    }

Mode detailed info about MediaManager, you can take a look:

Play Audio and Video with the MediaManager Plugin for Xamarin

https://github.com/Baseflow/XamarinMediaManager

Upvotes: 0

Related Questions