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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章