GlVideoView.java
23.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
package com.glsx.commonres.player.widget;
import android.content.Context;
import android.os.Handler;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.Toast;
import com.glsx.commonres.R;
import com.glsx.commonres.config.AppSrcConst;
import com.glsx.commonres.util.FlowCardOverdueStateCallback;
import com.blankj.utilcode.util.LogUtils;
import com.shuyu.gsyvideoplayer.GSYVideoManager;
import com.shuyu.gsyvideoplayer.model.VideoOptionModel;
import com.shuyu.gsyvideoplayer.utils.Debuger;
import com.shuyu.gsyvideoplayer.utils.GSYVideoType;
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer;
import com.shuyu.gsyvideoplayer.video.base.GSYVideoView;
import java.util.ArrayList;
import java.util.List;
import moe.codeest.enviews.ENDownloadView;
import moe.codeest.enviews.ENPlayView;
import tv.danmaku.ijk.media.player.IjkMediaPlayer;
/**
* 封装播放器控件
*/
public class GlVideoView extends StandardGSYVideoPlayer {
private String TAG = GlVideoView.class.getSimpleName();
private boolean mIsRecording = false;
public RelativeLayout layoutRecordState;
public LinearLayout layoutSwitchCamera;
private ImageView mIconCameraDir;
private ArrayList<RemoteVideoListener> remoteVideoListenerList = new ArrayList<>();
private boolean mIsUrlLiveStream = false;
private int mLastState = -1;
private RelativeLayout layoutTvTips;
private boolean isFlowCardOverdue = false;//流量卡过期状态 true:已过期
private FlowCardOverdueStateCallback overdueStateCallback;
public GlVideoView(Context context, Boolean fullFlag) {
super(context, fullFlag);
}
public GlVideoView(Context context) {
super(context);
}
public GlVideoView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void init(Context context) {
super.init(context);
mIsUrlLiveStream = false;
layoutRecordState = findViewById(R.id.rl_reord_state);
layoutSwitchCamera = findViewById(R.id.layout_remote_switch_camera);
layoutSwitchCamera.setVisibility(View.GONE);
layoutSwitchCamera.setOnClickListener(v -> notifyClickSwitchCamera());
mIconCameraDir = findViewById(R.id.icon_camera_dir);
layoutTvTips = findViewById(R.id.ll_tvTips);
ImageView watermark = findViewById(R.id.watermark);
if (AppSrcConst.APP_SRC == AppSrcConst.AICARLIFE) {
watermark.setBackgroundResource(R.drawable.public_app_watermark_aicarlife);
} else {
watermark.setBackgroundResource(R.drawable.public_app_watermark_aicar);
}
getFullscreenButton().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (GSYVideoView.CURRENT_STATE_PLAYING == getCurrentState()) {
startWindowFullscreen(context, false, true);
} else {
showToast("视频未开始播放");
}
}
});
}
/**
* 初始化播放器参数
*
* @param activity Context对象
*/
public void initParams(Context activity) {
// setAutoFullWithSize(true);
//是否使用全屏动画效果
setShowFullAnimation(false);
//是否可以滑动界面改变进度,声音等
setIsTouchWiget(false);
//是否可以全屏滑动界面改变进度,声音等
setIsTouchWigetFull(false);
//一全屏就锁屏横屏,默认false竖屏,可配合setRotateViewAuto使用
setLockLand(true);
//设置播放器视频参数
setVideoOptionModel();
//切换渲染模式
//GSYVideoType.setShowType(GSYVideoType.SCREEN_MATCH_FULL);
//默认显示比例
//GSYVideoType.SCREEN_TYPE_DEFAULT = 0;
//16:9
//GSYVideoType.SCREEN_TYPE_16_9 = 1;
//4:3
//GSYVideoType.SCREEN_TYPE_4_3 = 2;
//全屏裁减显示,为了显示正常 CoverImageView 建议使用FrameLayout作为父布局
//GSYVideoType.SCREEN_TYPE_FULL = 4;
//全屏拉伸显示,使用这个属性时,surface_container建议使用FrameLayout
GSYVideoType.setShowType(GSYVideoType.SCREEN_MATCH_FULL);
}
public void resetVideoOptionModel() {
setVideoOptionModel();
}
public void reInitParams(String url) {
}
/**
* 设置缩略图控件
*
* @param thumbView 缩略图控件
*/
public void setThumbImageView(ImageView thumbView) {
super.setThumbImageView(thumbView);
}
public void stopPlay() {
if (isIfCurrentIsFullscreen()) {
onBackFullscreen();
new Handler().postDelayed(this::stopPlay, 1500);
} else {
onVideoPause();
setupUrl("");
}
}
public void onDestroyView(RemoteVideoListener listener) {
mIsUrlLiveStream = false;
unregisterListener(listener);
setVideoAllCallBack(null);
GSYVideoManager.releaseAllVideos();
setupUrl("");
}
/**
* 设置播放URL,并立即播放
*
* @param url
*/
public void setNormalUrlAndPlayNow(String url) {
mIsUrlLiveStream = false;
if (!TextUtils.isEmpty(url)) {
// setupUrl(url);
startPlay();
}
}
/**
* 设置播放URL,点击播放按钮才开始播放
*
* @param url
*/
public void setNormalUrlAndClickPlay(String url) {
mIsUrlLiveStream = false;
// if (!TextUtils.isEmpty(url)) {
// setupUrl(url);
// }
}
/**
* 设置流播放连接,点击开始播放按钮请求直播流.
*
* @param url 流连接
*/
public void setLiveStreamUrlAndPlayNow(String url) {
mIsUrlLiveStream = true;
if (!TextUtils.isEmpty(url)) {
// setupUrl(url);
startPlay();
}
}
/**
* 转载播放连接
*
* @param url 播放连接
*/
private void setupUrl(String url) {
GSYVideoManager.releaseAllVideos();
getGSYVideoManager().releaseMediaPlayer();
super.onVideoReset();
setUp(url, true, "");
}
/**
* 开始播放
*/
private void startPlay() {
startPlayLogic();
onVideoResume();
}
/**
* 点击返回按钮先退出全屏模式
*
* @param activity Activity的Context对象
* @return true:退出全屏模式,false可以直接退出.
*/
public boolean onVideoBack(Context activity) {
return GSYVideoManager.backFromWindowFull(activity);
}
/**
* 替换默认视频布局,可用于自定义
*
* @return
*/
@Override
public int getLayoutId() {
return R.layout.public_layout_remote_video_player;
}
/**
* 设置全屏图片
*/
@Override
public int getEnlargeImageRes() {
return R.drawable.video_full_open;
}
/**
* 设置缩屏图片
*/
@Override
public int getShrinkImageRes() {
return R.drawable.video_full_close;
}
/**
* 注册播放状态回调监听,需要获取相应状态的页面需要注册
*
* @param listener 监听回调对象
*/
public void registerListener(RemoteVideoListener listener) {
if (remoteVideoListenerList != null)
remoteVideoListenerList.add(listener);
}
/**
* 注销播放状态回调监听,需要获取相应状态的页面需要注册
* * @param listener 监听回调对象
*/
public void unregisterListener(RemoteVideoListener listener) {
if (remoteVideoListenerList != null)
remoteVideoListenerList.remove(listener);
}
/**
* 播放按钮点击
*/
private void notifyClickStartBtn() {
for (int i = 0; i < remoteVideoListenerList.size(); i++) {
remoteVideoListenerList.get(i).onClickStartBtn();
}
}
private void resumePlay() {
if (!TextUtils.isEmpty(mOriginUrl)) {
onVideoResume();
}
}
/**
* 视频缓冲完成,开始播放
*/
private void notifyVideoPrepared() {
for (int i = 0; i < remoteVideoListenerList.size(); i++) {
remoteVideoListenerList.get(i).onPlayerPrepared();
}
}
/**
* 视频播放暂停
*/
private void notifyOnPause() {
for (int i = 0; i < remoteVideoListenerList.size(); i++) {
remoteVideoListenerList.get(i).onPlayerPause();
}
}
/**
* 视频播放停止
*/
private void notifyOnStop() {
for (int i = 0; i < remoteVideoListenerList.size(); i++) {
remoteVideoListenerList.get(i).onPlayerStop();
}
}
/**
* 缓冲链接超时
*/
private void notifyTimeOut() {
for (int i = 0; i < remoteVideoListenerList.size(); i++) {
remoteVideoListenerList.get(i).onPlayerCacheTimeOut();
}
}
@Override
protected void changeUiToPreparingShow() {
Debuger.printfLog("changeUiToPreparingShow");
setViewShowState(mTopContainer, View.VISIBLE);
setViewShowState(mBottomContainer, View.VISIBLE);
setViewShowState(mStartButton, View.INVISIBLE);
setViewShowState(mLoadingProgressBar, View.VISIBLE);
setViewShowState(mThumbImageViewLayout, View.INVISIBLE);
setViewShowState(mBottomProgressBar, View.INVISIBLE);
setViewShowState(mLockScreen, View.GONE);
if (mLoadingProgressBar instanceof ENDownloadView) {
ENDownloadView enDownloadView = (ENDownloadView) mLoadingProgressBar;
if (enDownloadView.getCurrentState() == ENDownloadView.STATE_PRE) {
((ENDownloadView) mLoadingProgressBar).start();
mLoadingProgressBar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
notifyOnStop();
}
});
}
}
layoutTvTips.setVisibility(View.GONE);
notifyVideoPrepared();
}
@Override
protected void hideAllWidget() {
LogUtils.vTag(TAG, "hideAllWidget mCurrentState:" + mCurrentState);
setViewShowState(mBottomContainer, View.INVISIBLE);
setViewShowState(mTopContainer, View.INVISIBLE);
setViewShowState(mBottomProgressBar, View.VISIBLE);
//避免为开始播放器时,播放按钮无故消失问题
if (mCurrentState != -1)
setViewShowState(mStartButton, View.INVISIBLE);
}
@Override
protected void changeUiToPauseShow() {
Debuger.printfLog("changeUiToPauseShow");
setViewShowState(mTopContainer, View.VISIBLE);
setViewShowState(mStartButton, View.VISIBLE);
setViewShowState(mLoadingProgressBar, View.INVISIBLE);
setViewShowState(mThumbImageViewLayout, View.INVISIBLE);
setViewShowState(mBottomProgressBar, View.INVISIBLE);
setViewShowState(mLockScreen, (mIfCurrentIsFullscreen && mNeedLockFull) ? View.VISIBLE : View.GONE);
if (mLoadingProgressBar instanceof ENDownloadView) {
((ENDownloadView) mLoadingProgressBar).reset();
}
updateStartImage();
updatePauseCover();
}
@Override
protected void changeUiToPlayingShow() {
Debuger.printfLog("changeUiToPlayingShow");
setViewShowState(mTopContainer, View.VISIBLE);
setViewShowState(mBottomContainer, View.INVISIBLE);
setViewShowState(mStartButton, View.VISIBLE);
setViewShowState(mLoadingProgressBar, View.INVISIBLE);
setViewShowState(mThumbImageViewLayout, View.INVISIBLE);
setViewShowState(mBottomProgressBar, View.INVISIBLE);
setViewShowState(mLockScreen, (mIfCurrentIsFullscreen && mNeedLockFull) ? View.VISIBLE : View.GONE);
layoutTvTips.setVisibility(View.GONE);
if (mLoadingProgressBar instanceof ENDownloadView) {
((ENDownloadView) mLoadingProgressBar).reset();
}
updateStartImage();
}
@Override
protected void touchSurfaceMoveFullLogic(float absDeltaX, float absDeltaY) {
super.touchSurfaceMoveFullLogic(absDeltaX, absDeltaY);
//强制取消直播设置滑动
mChangePosition = false;
}
@Override
public void onVideoPause() {
super.onVideoPause();
}
@Override
public void onVideoResume() {
super.onVideoResume();
}
@Override
protected void clickStartIcon() {
LogUtils.vTag(TAG, "mCurrentState:" + mCurrentState + ",OriginUrl is = " + mOriginUrl);
Debuger.printfLog("clickStartIcon:" + mCurrentState);
//点击远程直播,播放按钮,不再触发到期续费提醒
// if (isFlowCardOverdue) {
// overdueStateCallback.onStartBtnClick();
// return;
// }
if (TextUtils.isEmpty(mOriginUrl)) {
if (mCurrentState == -1 || mCurrentState == GSYVideoView.CURRENT_STATE_NORMAL) {
// prepareVideo();
setViewShowState(mStartButton, View.INVISIBLE);
}
notifyClickStartBtn();
layoutTvTips.setVisibility(View.VISIBLE);
return;
}
super.clickStartIcon();
if (mCurrentState == GSYVideoView.CURRENT_STATE_PLAYING) {
if (mIsUrlLiveStream) {
notifyClickStartBtn();
} else {
if (GSYVideoView.CURRENT_STATE_PAUSE == mLastState) {
resumePlay();
} else {
if (!TextUtils.isEmpty(mOriginUrl)) {
startPlay();
} else {
notifyClickStartBtn();
}
}
}
} else if (mCurrentState == GSYVideoView.CURRENT_STATE_PAUSE) {
notifyOnPause();
layoutTvTips.setVisibility(View.GONE);
} else if (mCurrentState == GSYVideoView.CURRENT_STATE_PREPAREING
|| mCurrentState == GSYVideoView.CURRENT_STATE_NORMAL) {
prepareVideo();
}
mLastState = mCurrentState;
}
@Override
protected void updateStartImage() {
if (mStartButton instanceof ENPlayView) {
ENPlayView enPlayView = (ENPlayView) mStartButton;
enPlayView.setDuration(500);
if (mCurrentState == GSYVideoView.CURRENT_STATE_PLAYING) {
enPlayView.play();
} else if (mCurrentState == GSYVideoView.CURRENT_STATE_ERROR) {
enPlayView.pause();
} else {
enPlayView.pause();
}
} else if (mStartButton instanceof ImageView) {
ImageView imageView = (ImageView) mStartButton;
if (mCurrentState == GSYVideoView.CURRENT_STATE_PLAYING) {
imageView.setImageResource(R.drawable.video_click_pause_selector);
layoutRecordState.setVisibility(View.VISIBLE);
} else if (mCurrentState == GSYVideoView.CURRENT_STATE_ERROR) {
imageView.setImageResource(R.drawable.video_click_error_selector);
layoutRecordState.setVisibility(View.GONE);
layoutTvTips.setVisibility(GONE);
notifyOnStop();
} else {
imageView.setImageResource(R.drawable.public_btn_preview_start);
layoutRecordState.setVisibility(View.GONE);
layoutTvTips.setVisibility(GONE);
}
if (!mIsRecording) {
layoutRecordState.setVisibility(View.GONE);
}
}
}
@Override
public void onError(int what, int extra) {
LogUtils.eTag(TAG, "播放错误,error = " + what+" OriginUrl is = " + mOriginUrl);
layoutTvTips.setVisibility(GONE);
if (IjkMediaPlayer.MEDIA_ERROR_TIMED_OUT == what) {
notifyTimeOut();
}
//播放错误后直接停止播放,不执行默认的继续播放逻辑
if (-10000 == what) {
notifyTimeOut();
super.onError(what, extra);
}
}
/**
* 设置是否显示录像状态UI
*
* @param isRecording 是否录像状态.回看页面为非录像状态
*/
public void setRecordState(boolean isRecording) {
mIsRecording = isRecording;
// if (!isRecording) {
// setShowFullscreenBtn(false);
// }
}
/**
* 是否显示全屏按钮
*
* @param isShow 是否显示
*/
public void setShowFullscreenBtn(boolean isShow) {
setViewShowState(mFullscreenButton, isShow ? View.VISIBLE : View.GONE);
}
private void showToast(String text) {
if (null != mContext) {
Toast.makeText(mContext, text, Toast.LENGTH_SHORT).show();
}
}
/**
* 设置全屏按钮点击监听
* @param listener
*/
public void setFullScreenBtnClickListener(View.OnClickListener listener) {
if (null != listener) {
mFullscreenButton.setOnClickListener(listener);
}
}
/**
* 设置播放器视频参数
*/
public void setVideoOptionModel() {
List<VideoOptionModel> list = new ArrayList<>();
//不额外优化
VideoOptionModel videoOptionMode01 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "fast", 1);
list.add(videoOptionMode01);
//每处理一个packet之后刷新io上下文
VideoOptionModel videoOptionMode02 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "flush_packets", 1);
list.add(videoOptionMode02);
//跳帧处理,放CPU处理较慢时,进行跳帧处理,保证播放流程,画面和声音同步:0-120
VideoOptionModel videoOptionMode03 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "framedrop", 5);//丢帧,太卡可以尝试丢帧
list.add(videoOptionMode03);
//需要准备好后自动播放
VideoOptionModel videoOptionMode04 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "start-on-prepared", 1);
list.add(videoOptionMode04);
//设置是否开启环路过滤: 0开启,画面质量高,解码开销大,48关闭,画面质量差点,解码开销小
VideoOptionModel videoOptionMode05 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_CODEC, "skip_loop_filter", 48);
list.add(videoOptionMode05);
//最小fps
VideoOptionModel videoOptionMode06 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "min-frames", 2);
list.add(videoOptionMode06);
//最大缓冲大小,单位kb默认为0
VideoOptionModel videoOptionMode07 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "max-buffer-size", 0);
list.add(videoOptionMode07);
//最大缓存时长
VideoOptionModel videoOptionMode08 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "max_cached_duration", 30);
list.add(videoOptionMode08);
//是否限制输入缓存数
VideoOptionModel videoOptionMode09 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "infbuf", 1);
list.add(videoOptionMode09);
VideoOptionModel videoOptionMode10 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "fflags", "nobuffer");
list.add(videoOptionMode10);
//是否开启预缓冲,一般直播项目会开启,达到秒开的效果,不过带来了播放丢帧卡顿的体验
VideoOptionModel videoOptionMode11 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "packet-buffering", 0);
list.add(videoOptionMode11);
//tcp传输数据
VideoOptionModel videoOptionMode12 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "rtsp_transport", "tcp");
list.add(videoOptionMode12);
//播放前的探测Size,默认是1M, 改小一点会出画面更快
VideoOptionModel videoOptionMode13 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "probesize", 1024);//10240//200
list.add(videoOptionMode13);
//设置播放前的最大探测时间
VideoOptionModel videoOptionMode14 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "analyzedmaxduration", 100);
list.add(videoOptionMode14);
//设置播放前的探测时间 1,达到首屏秒开效果
VideoOptionModel videoOptionMode15 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "analyzeduration", 1);
list.add(videoOptionMode15);
//播放重连次数
VideoOptionModel videoOptionModel16 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "reconnect", 3);
list.add(videoOptionModel16);
//增加后可以避免播放器报-10000的错误
VideoOptionModel videoOptionModel17 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "dns_cache_clear", 1);
list.add(videoOptionModel17);
/*VideoOptionModel videoOptionModel19 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "mediacodec", 1);
list.add(videoOptionModel19);
VideoOptionModel videoOptionModel20 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "mediacodec-auto-rotate", 1);
list.add(videoOptionModel20);
VideoOptionModel videoOptionModel21 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_PLAYER, "mediacodec-handle-resolution-change", 1);
list.add(videoOptionModel21);*/
/*VideoOptionModel videoOptionMode18 = new VideoOptionModel(IjkMediaPlayer.OPT_CATEGORY_FORMAT, "timeout", 5000);//超时时间
list.add(videoOptionMode18);*/
GSYVideoManager.instance().setOptionModelList(list);
GSYVideoManager.instance().setTimeOut(1000, true);
}
public void setShowTitle(boolean isShow) {
getTitleTextView().setVisibility(isShow ? View.VISIBLE : View.GONE);
}
public void setShowBackBtn(boolean isShow) {
getBackButton().setVisibility(isShow ? View.VISIBLE : View.GONE);
}
public void setIsTouchWidget(boolean isTouchWidget) {
super.setIsTouchWiget(false);
}
public void pausePlay() {
getGSYVideoManager().pause();
}
public boolean isPlaying() {
return getGSYVideoManager().isPlaying();
}
public void setTimeout(int timeOut) {
GSYVideoManager.instance().setTimeOut(timeOut, true);
}
public void showHideSwitchCamera(boolean isShow) {
layoutSwitchCamera.setVisibility(isShow ? VISIBLE : GONE);
}
public void updateCameraDirIcon(boolean isFront) {
mIconCameraDir.setBackgroundResource(
isFront ? R.drawable.icon_switch_camera_front : R.drawable.icon_switch_camera_back);
}
/**
* 点击切换摄像头按钮的通知
*/
private void notifyClickSwitchCamera() {
for (int i = 0; i < remoteVideoListenerList.size(); i++) {
remoteVideoListenerList.get(i).onClickSwitchCamera();
}
}
public interface RemoteVideoListener {
void onClickStartBtn();
void onPlayerPrepared();
void onPlayerPause();
void onPlayerStop();
void onPlayerCacheTimeOut();
void onClickSwitchCamera();
}
/**
* 更新流量卡过期状态
*
* @param isOverdue
*/
public void updateOverdueState(boolean isOverdue, FlowCardOverdueStateCallback callback) {
isFlowCardOverdue = isOverdue;
overdueStateCallback = callback;
}
/**
* 远程直播切换到全屏后播放画面会暂停,需要调用播放操作20210902 mark
*/
public void remoteLiveFullscreen() {
startWindowFullscreen(mContext,false,true).startPlayLogic();
}
}