11、使用xamarin实现全屏播放rtmp之类的直播视频

直播类的app大部分都是以rtmp hls播放为主。目前主流的app解决方案大部分是引入ijkplayer 这个是基于ffmpeg中的ffplayer实现的。

众所周知ffmpeg的解码能力是一流的。暴风xx  xx解码之类都是基于ffmpeg魔改出来的。七牛的直播就是基于Ijkplayer实现的

下面我介绍如何使用QiNiu.PLPlayer.Droid 实现全屏直播  

https://github.com/jsonsugar/QiNiu.PLPlayer.Droid

首先创建一个默认的xamarin.android库然后实现 引入上面的绑定库

记得 下载一个libs 

 

然后设置main.xaml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" 
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <com.pili.pldroid.player.widget.PLVideoView
        android:id="@+id/PLVideoView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center" />
</LinearLayout>

在mainactivity 加入下面代码

 [Activity(Label = "视频直播", MainLauncher = true, ConfigurationChanges = Android.Content.PM.ConfigChanges.Orientation,
        ScreenOrientation = Android.Content.PM.ScreenOrientation.Landscape,
        Icon = "@drawable/icon")]
    public class MainActivity : Activity
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            //Quanp
            RequestWindowFeature(Android.Views.WindowFeatures.NoTitle);// 隐藏标题

            Window.SetFlags(Android.Views.WindowManagerFlags.Fullscreen, Android.Views.WindowManagerFlags.Fullscreen);// 设置全屏 
            SetContentView(Resource.Layout.Main);
            PLVideoView mVideoView = FindViewById<PLVideoView>(Resource.Id.PLVideoView);
            mVideoView.SetVideoPath("rtmp://live.hkstv.hk.lxdns.com/live/hks");

        }
    }

完成

https://github.com/jsonsugar/QiNiu.PLPlayer.DroidDemo

 

posted @ 2018-02-25 18:43  dotNET界面-大白  阅读(1443)  评论(0编辑  收藏  举报