GSYVideoPlayer
使用
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
下面三种选一种
implementation 'com.github.CarGuo.GSYVideoPlayer:gsyVideoPlayer:v8.1.3-jitpack'
implementation 'com.github.CarGuo.GSYVideoPlayer:gsyVideoPlayer-java:v8.1.3-jitpack'
implementation 'com.github.CarGuo.GSYVideoPlayer:gsyVideoPlayer-exo_player2:v8.1.3-jitpack'
implementation 'com.github.CarGuo.GSYVideoPlayer:gsyVideoPlayer-armv64:v8.1.3-jitpack'
implementation 'com.github.CarGuo.GSYVideoPlayer:gsyVideoPlayer-armv7a:v8.1.3-jitpack'
implementation 'com.github.CarGuo.GSYVideoPlayer:gsyVideoPlayer-armv5:v8.1.3-jitpack'
implementation 'com.github.CarGuo.GSYVideoPlayer:gsyVideoPlayer-x86:v8.1.3-jitpack'
implementation 'com.github.CarGuo.GSYVideoPlayer:gsyVideoPlayer-x86_64:v8.1.3-jitpack''
implementation 'com.github.CarGuo.GSYVideoPlayer:gsyVideoPlayer-java:v8.1.3-jitpack'
implementation 'com.github.CarGuo.GSYVideoPlayer:gsyVideoPlayer-exo_player2:v8.1.3-jitpack'
implementation 'com.github.CarGuo.GSYVideoPlayer:gsyVideoPlayer-ex_so:v8.1.3-jitpack'
布局中使用
<com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer
android:id="@+id/detail_player"
android:layout_width="match_parent"
android:layout_height="@dimen/post_media_height" />
java文件中
oncreated
orientationUtils = new OrientationUtils(this, detailPlayer);
orientationUtils.setEnable(false);
GSYVideoOptionBuilder gsyVideoOption = new GSYVideoOptionBuilder();
gsyVideoOption.setThumbImageView(imageView)
.setIsTouchWiget(true)
.setRotateViewAuto(false)
.setLockLand(false)
.setAutoFullWithSize(true)
.setShowFullAnimation(false)
.setNeedLockFull(true)
.setUrl(url)
.setCacheWithPlay(false)
.setVideoTitle("测试视频")
.setVideoAllCallBack(new GSYSampleCallBack() {
@Override
public void onPrepared(String url, Object... objects) {
super.onPrepared(url, objects);
orientationUtils.setEnable(true);
isPlay = true;
}
@Override
public void onQuitFullscreen(String url, Object... objects) {
super.onQuitFullscreen(url, objects);
Debuger.printfError("***** onQuitFullscreen **** " + objects[0]);
Debuger.printfError("***** onQuitFullscreen **** " + objects[1]);
if (orientationUtils != null) {
orientationUtils.backToProtVideo();
}
}
}).setLockClickListener(new LockClickListener() {
@Override
public void onClick(View view, boolean lock) {
if (orientationUtils != null) {
orientationUtils.setEnable(!lock);
}
}
}).build(detailPlayer);
detailPlayer.getFullscreenButton().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
orientationUtils.resolveByClick();
detailPlayer.startWindowFullscreen(SimpleDetailActivityMode2.this, true, true);
}
});
配置生命周期
@Override
public void onBackPressed() {
if (orientationUtils != null) {
orientationUtils.backToProtVideo();
}
if (GSYVideoManager.backFromWindowFull(this)) {
return;
}
super.onBackPressed();
}
@Override
protected void onPause() {
detailPlayer.getCurrentPlayer().onVideoPause();
super.onPause();
isPause = true;
}
@Override
protected void onResume() {
detailPlayer.getCurrentPlayer().onVideoResume(false);
super.onResume();
isPause = false;
}
@Override
protected void onDestroy() {
super.onDestroy();
if (isPlay) {
detailPlayer.getCurrentPlayer().release();
}
if (orientationUtils != null)
orientationUtils.releaseListener();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (isPlay && !isPause) {
detailPlayer.onConfigurationChanged(this, newConfig, orientationUtils, true, true);
}
}
更多使用
ExoSourceManager.setExoMediaSourceInterceptListener(new ExoMediaSourceInterceptListener() {
@Override
public MediaSource getMediaSource(String dataSource, boolean preview, boolean cacheEnable, boolean isLooping, File cacheDir) {
return null;
}
});
GSYVideoType.setShowType(GSYVideoType.SCREEN_TYPE_DEFAULT);
GSYVideoType.setShowType(GSYVideoType.SCREEN_TYPE_16_9);
GSYVideoType.setShowType(GSYVideoType.SCREEN_TYPE_FULL);
GSYVideoType.setShowType(GSYVideoType.SCREEN_MATCH_FULL);
GSYVideoType.setShowType(GSYVideoType.SCREEN_TYPE_4_3);
GSYVideoType.setRenderType(GSYVideoType.TEXTURE);
GSYVideoType.setRenderType(GSYVideoType.SUFRACE);
GSYVideoType.setRenderType(GSYVideoType.GLSURFACE);