Skip to content

Commit

Permalink
fix #3999
Browse files Browse the repository at this point in the history
  • Loading branch information
CarGuo committed Jun 17, 2024
1 parent adfabb4 commit 22c0d75
Showing 1 changed file with 23 additions and 28 deletions.
51 changes: 23 additions & 28 deletions app/src/main/java/com/example/gsyvideoplayer/DetailPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
import com.shuyu.gsyvideoplayer.listener.GSYVideoProgressListener;
import com.shuyu.gsyvideoplayer.listener.LockClickListener;
import com.shuyu.gsyvideoplayer.model.VideoOptionModel;
import com.shuyu.gsyvideoplayer.player.IPlayerManager;
import com.shuyu.gsyvideoplayer.player.SystemPlayerManager;
import com.shuyu.gsyvideoplayer.utils.Debuger;
import com.shuyu.gsyvideoplayer.utils.OrientationUtils;
import com.shuyu.gsyvideoplayer.video.base.GSYVideoPlayer;
Expand Down Expand Up @@ -147,22 +149,10 @@ protected void onCreate(Bundle savedInstanceState) {
header.put("allowCrossProtocolRedirects", "true");
header.put("User-Agent", "GSY");
GSYVideoOptionBuilder gsyVideoOption = new GSYVideoOptionBuilder();
gsyVideoOption.setThumbImageView(imageView)
.setIsTouchWiget(true)
.setRotateViewAuto(false)
gsyVideoOption.setThumbImageView(imageView).setIsTouchWiget(true).setRotateViewAuto(false)
//仅仅横屏旋转,不变直
//.setOnlyRotateLand(true)
.setRotateWithSystem(false)
.setLockLand(true)
.setAutoFullWithSize(true)
.setShowFullAnimation(false)
.setNeedLockFull(true)
.setUrl(url)
.setMapHeadData(header)
.setCacheWithPlay(false)
.setSurfaceErrorPlay(false)
.setVideoTitle("测试视频")
.setVideoAllCallBack(new GSYSampleCallBack() {
.setRotateWithSystem(false).setLockLand(true).setAutoFullWithSize(true).setShowFullAnimation(false).setNeedLockFull(true).setUrl(url).setMapHeadData(header).setCacheWithPlay(false).setSurfaceErrorPlay(false).setVideoTitle("测试视频").setVideoAllCallBack(new GSYSampleCallBack() {
@Override
public void onPrepared(String url, Object... objects) {
Debuger.printfError("***** onPrepared **** " + objects[0]);
Expand Down Expand Up @@ -208,6 +198,19 @@ public void onEnterFullscreen(String url, Object... objects) {
@Override
public void onAutoComplete(String url, Object... objects) {
super.onAutoComplete(url, objects);
IPlayerManager playerManager = binding.detailPlayer.getGSYVideoManager().getPlayer();
if (playerManager instanceof SystemPlayerManager) {
playerManager.release();
}
}

@Override
public void onComplete(String url, Object... objects) {
super.onComplete(url, objects);
IPlayerManager playerManager = binding.detailPlayer.getGSYVideoManager().getPlayer();
if (playerManager instanceof SystemPlayerManager) {
playerManager.release();
}
}

@Override
Expand Down Expand Up @@ -346,23 +349,20 @@ public void onPlayError(String url, Object... objects) {
Debuger.printfError("#######################");
}
}
})
.setLockClickListener(new LockClickListener() {
}).setLockClickListener(new LockClickListener() {
@Override
public void onClick(View view, boolean lock) {
if (orientationUtils != null) {
//配合下方的onConfigurationChanged
orientationUtils.setEnable(!lock);
}
}
})
.setGSYVideoProgressListener(new GSYVideoProgressListener() {
}).setGSYVideoProgressListener(new GSYVideoProgressListener() {
@Override
public void onProgress(long progress, long secProgress, long currentPosition, long duration) {
Debuger.printfLog(" progress " + progress + " secProgress " + secProgress + " currentPosition " + currentPosition + " duration " + duration);
}
})
.build(binding.detailPlayer);
}).build(binding.detailPlayer);

binding.detailPlayer.getFullscreenButton().setOnClickListener(new View.OnClickListener() {
@Override
Expand Down Expand Up @@ -410,9 +410,7 @@ public void onClick(View view) {
return;
}
TrackGroup trackGroup = rendererTrackGroups.get(index);
TrackSelectionParameters parameters = trackSelector.getParameters().buildUpon()
.setForceHighestSupportedBitrate(true)
.setOverrideForType(new TrackSelectionOverride(trackGroup, 0)).build();
TrackSelectionParameters parameters = trackSelector.getParameters().buildUpon().setForceHighestSupportedBitrate(true).setOverrideForType(new TrackSelectionOverride(trackGroup, 0)).build();
trackSelector.setParameters(parameters);
}
}
Expand Down Expand Up @@ -459,8 +457,7 @@ protected void onDestroy() {
getCurPlay().release();
}
//GSYPreViewManager.instance().releaseMediaPlayer();
if (orientationUtils != null)
orientationUtils.releaseListener();
if (orientationUtils != null) orientationUtils.releaseListener();
}


Expand Down Expand Up @@ -586,9 +583,7 @@ protected void onActivityResult(int requestCode, int resultCode, @Nullable Inten

private void getPathForSearch(Uri uri) {
String[] selectionArgs = new String[]{DocumentsContract.getDocumentId(uri).split(":")[1]};
Cursor cursor = getContentResolver().query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
null, MediaStore.Images.Media._ID + "=?",
selectionArgs, null);
Cursor cursor = getContentResolver().query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, null, MediaStore.Images.Media._ID + "=?", selectionArgs, null);
if (null != cursor) {
if (cursor.moveToFirst()) {
int index = cursor.getColumnIndex(MediaStore.Video.Media.DATA);
Expand Down

0 comments on commit 22c0d75

Please sign in to comment.