RTMP、RTSP、HTTP协议都属于互联网 TCP/IP 五层体系结构中应用层的协议。理论上这三种都可以用来做视频直播或点播。但通常来说,直播一般用 RTMP、RTSP。而点播用 HTTP。
Android平台播放RTMP流媒体采用了GiraffePlayer2,使用前可在build.gradle中引入:
api 'com.github.tcking:giraffeplayer2:0.1.25'
api 'com.github.tcking:ijkplayer-arm64:0.8.8' //support arm64
api 'com.github.tcking:ijkplayer-armv5:0.8.8' //support armv5
api 'com.github.tcking:ijkplayer-x86:0.8.8' //support x86
api 'com.github.tcking:ijkplayer-x86_64:0.8.8' //support x86_64
1、全屏播放
GiraffePlayer.play(getContext(), new VideoInfo("video url"));
2、在Layout文件中使用
在layout xml文件中添加VideoView:
<tcking.github.com.giraffeplayer2.VideoView
android:id="@+id/video_view"
android:layout_width="xxx"
android:layout_height="xxx"/>
代码中调用: