We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
接入直播视频RTSP,在列表点击后传入路径动态播放对应视频!
真机 三星 Note4 Android6.0.1
implementation ('com.shuyu:gsyVideoPlayer-java:6.0.3'){ exclude group :'com.android.support',module:'appcompat-v7' }
implementation 'com.shuyu:GSYVideoPlayer-exo2:6.0.3' implementation 'com.shuyu:gsyVideoPlayer-ex_so:6.0.3'
implementation 'com.shuyu:GSYVideoPlayer-exo2:6.0.3'
implementation 'com.shuyu:gsyVideoPlayer-ex_so:6.0.3'
问题代码:
public class VideoPlayerActivity extends BaseActivity { StandardGSYVideoPlayer videoPlayer; OrientationUtils orientationUtils; private String mSource; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_video_player); setHeadVisibility(View.GONE); initData(); //初始化数据 init(); } private void initData(){ boolean state = getIntent().getBooleanExtra("state", true); if(state){ mSource = "rtsp://admin:jomi2016@112.94.22.29:1554"; }else{ mSource = "rtsp://admin:jomi2016@112.94.22.29:2554"; } /*if(state){ mSource = "http://9890.vod.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4"; }else{ mSource = "http://wdquan-space.b0.upaiyun.com/VIDEO/2018/11/22/ae0645396048_hls_time10.m3u8"; }*/ NToast.shortToast("点击了"+mSource); } private void init() { videoPlayer = (StandardGSYVideoPlayer)findViewById(R.id.video_player); /**此中内容:优化加载速度,降低延迟*/ VideoOptionModel videoOptionModel; List<VideoOptionModel> list = new ArrayList<>(); videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "rtsp_transport", "tcp"); list.add(videoOptionModel); videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "rtsp_flags", "prefer_tcp"); list.add(videoOptionModel); // videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "allowed_media_types", "video"); //根据媒体类型来配置 // list.add(videoOptionModel); videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "timeout", 20000); list.add(videoOptionModel); videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "buffer_size", 1316); list.add(videoOptionModel); videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "infbuf", 1); // 无限读 list.add(videoOptionModel); videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "analyzemaxduration", 100); list.add(videoOptionModel); // videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "probesize", 10240); // list.add(videoOptionModel); videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "flush_packets", 1); list.add(videoOptionModel); // 跳帧开关,如果cpu解码能力不足,可以设置成5,否则会引起音视频不同步,也可以通过设置它来跳帧达到倍速播放 videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "framedrop", 5); list.add(videoOptionModel); // 关闭播放器缓冲,这个必须关闭,否则会出现播放一段时间后,一直卡主,控制台打印 FFP_MSG_BUFFERING_START videoOptionModel = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "packet-buffering", 0); list.add(videoOptionModel); GSYVideoManager.instance().setOptionModelList(list); // String source1 = "rtsp://184.72.239.149/vod/mp4://BigBuckBunny_175k.mov"; // String source1 = "rtmp://58.200.131.2:1935/livetv/hunantv"; videoPlayer.setUp(mSource, true, "测试视频"); //增加title videoPlayer.getTitleTextView().setVisibility(View.VISIBLE); //设置返回键 videoPlayer.getBackButton().setVisibility(View.VISIBLE); //设置返回按键功能 videoPlayer.getBackButton().setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { onBackPressed(); } }); //设置旋转 orientationUtils = new OrientationUtils(this, videoPlayer); //设置全屏按键功能,这是使用的是选择屏幕,而不是全屏 videoPlayer.getFullscreenButton().setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { orientationUtils.resolveByClick(); } }); //是否可以滑动调整 videoPlayer.setIsTouchWiget(true); videoPlayer.startPlayLogic(); } @Override protected void onPause() { super.onPause(); videoPlayer.onVideoPause(); } @Override protected void onResume() { super.onResume(); videoPlayer.onVideoResume(); } @Override protected void onDestroy() { super.onDestroy(); GSYVideoManager.releaseAllVideos(); if (orientationUtils != null) orientationUtils.releaseListener(); } @Override public void onBackPressed() { //先返回正常状态 if (orientationUtils.getScreenType() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) { videoPlayer.getFullscreenButton().performClick(); return; } //释放所有 videoPlayer.setVideoAllCallBack(null); super.onBackPressed(); } }
xxxxxxx
The text was updated successfully, but these errors were encountered:
我记得以前遇到过,目前对于同个域下不同断开切换没办法处理。
Sorry, something went wrong.
#2112
No branches or pull requests
问题描述:
接入直播视频RTSP,在列表点击后传入路径动态播放对应视频!
问题机型/系统:
真机 三星 Note4 Android6.0.1
GSY依赖版本
implementation 'com.shuyu:GSYVideoPlayer-exo2:6.0.3'
implementation 'com.shuyu:gsyVideoPlayer-ex_so:6.0.3'
Demo中的复现步骤
问题代码:
问题log(如果有)
The text was updated successfully, but these errors were encountered: