rtmp流接收

由于目前android官网所提供控件不支持接收rtmp网络流,所以从网上找了一些第三方控件,许多人说使用Vitamio,https://github.com/yixia/VitamioBundle这是vitamio的下载地址,但是我发现该项目已经好几年没有维护,可以说是一个老旧的项目。为了寻找一个免费的项目,又是各种搜索。最终锁定了GiraffePlayer2https://github.com/tcking/GiraffePlayer2这是github地址。然后本人就起了一个Demo去演示该项目的可用性。为了验证是否可以播放rtmp流,那还的找一个rtmp流,又是一顿找,最终找了这么一个地址:湖南卫视,rtmp://58.200.131.2:1935/livetv/hunantv,本人校对过,可以使用,参考文章:https://www.jianshu.com/p/8f29fc3bf3df

接下来就按照官网的需求去使用该控件,以下为需要集成的代码.

1、在build.gradle中引入该控件

 implementation 'com.github.tcking:giraffeplayer2:0.1.25-lazyLoad'

    //for all decoders
    implementation 'com.github.tcking:ijkplayer-arm64:0.8.8-full' //support arm64
    implementation 'com.github.tcking:ijkplayer-armv5:0.8.8-full' //support armv5
    implementation 'com.github.tcking:ijkplayer-x86:0.8.8-full' //support x86
    implementation 'com.github.tcking:ijkplayer-x86_64:0.8.8-full' //support x86_64

2、在布局文件中引入控件

 <tcking.github.com.giraffeplayer2.VideoView
        android:id="@+id/video_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

3、在页面为控件设置url,然后启动控件

videoView.setVideoPath(trim).getPlayer().start()

4、demo下载地址:
https://download.csdn.net/download/zhizhuodewo6/12287801

发布了342 篇原创文章 · 获赞 60 · 访问量 25万+

猜你喜欢

转载自blog.csdn.net/zhizhuodewo6/article/details/105219179