直播页面5:项目中的直播播放器框架GSYVideoPlayer
一.github地址
https://github.com/CarGuo/GSYVideoPlayer
二.代码
0.快手官网获得直播地址
https://live.kuaishou.com
1.xml布局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
tools:context=".test.ZhiBoActivity"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer
android:id="@+id/gsy"
android:layout_width="match_parent"
android:layout_height="match_parent"></com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer>
</RelativeLayout>
2.java代码
public class ZhiBoActivity extends AppCompatActivity {
private GSYVideoPlayer gsyVideoPlayer;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_zhi_bo);
gsyVideoPlayer = findViewById(R.id.gsy);
//客户端启动
gsyVideoPlayer.onVideoResume();
//设置进行全屏播放
// GSYVideoType.setShowType(GSYVideoType.SCREEN_TYPE_CUSTOM);
//设置URL
gsyVideoPlayer.setUp("https://tx-adaptive.pull.yximgs.com/gifshow/2YH0jtzY7ZQ.flv?txSecret=9f7ecab9699292d8e41eff90b45dacdf&txTime=62f3689f&stat=3e%2FMqmuA1li8krumyImlBq5j5q8pn7LxE8eVZjmHclCIuRrCx44GfC5wQnktMZ9l&oidc=watchmen&sidc=5907&fd=1&ss=s20&kabr_spts=-5000https://tx-adaptive.pull.yximgs.com/gifshow/2YH0jtzY7ZQ.flv?txSecret=9f7ecab9699292d8e41eff90b45dacdf&txTime=62f3689f&stat=3e%2FMqmuA1li8krumyImlBq5j5q8pn7LxE8eVZjmHclCIuRrCx44GfC5wQnktMZ9l&oidc=watchmen&sidc=5907&fd=1&ss=s20&kabr_spts=-5000",false,"直播");
//播放
gsyVideoPlayer.startPlayLogic();
}
}