Skip to content

Commit e808d31

Browse files
author
kongdywang
committed
1. Fix an issue where the window size and aspect ratio of the picture-in-picture mode do not match when entering picture-in-picture during Android live streaming.
2. Remove the delay operation for rotating the screen in the player component.
1 parent 6619ac8 commit e808d31

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

Flutter/android/src/main/java/com/tencent/vod/flutter/player/FTXLivePlayer.java

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ public class FTXLivePlayer extends FTXLivePlayerRenderHost implements TXFlutterL
6767
private FTXRenderView mCurRenderView;
6868
private final Handler mUIHandler = new Handler(Looper.getMainLooper());
6969
private boolean mIsMute = false;
70+
private int mCurrentVideoWidth = 0;
71+
private int mCurrentVideoHeight = 0;
7072

7173
private final FTXPIPManager.PipCallback pipCallback = new FTXPIPManager.PipCallback() {
7274
@Override
@@ -178,6 +180,8 @@ int stopPlay(boolean isNeedClearLastImg) {
178180
result = mLivePlayer.stopPlay();
179181
}
180182
mUIHandler.removeCallbacksAndMessages(null);
183+
mCurrentVideoWidth = 0;
184+
mCurrentVideoHeight = 0;
181185
if (isNeedClearLastImg && null != mCurRenderView) {
182186
LiteavLog.i(TAG, "stopPlay target clear last img, player:" + hashCode());
183187
mCurRenderView.clearTexture();
@@ -370,11 +374,19 @@ public IntMsg enterPictureInPictureMode(@NonNull PipParamsPlayerMsg pipParamsMsg
370374
mPipManager.toAndroidPath(pipParamsMsg.getPauseIconForAndroid()),
371375
mPipManager.toAndroidPath(pipParamsMsg.getForwardIconForAndroid()),
372376
getPlayerId(), false, false, true);
373-
pipParams.setIsPlaying(isPlayerPlaying());
374-
int pipResult = mPipManager.enterPip(pipParams, new TXPlayerHolder(mLivePlayer, mIsPaused));
375-
// After the startup is successful, pause the video on the current interface.
376-
if (pipResult == FTXEvent.NO_ERROR) {
377-
pausePlayer();
377+
int pipResult = FTXEvent.ERROR_PIP_MISS_PLAYER;
378+
if (null != mLivePlayer) {
379+
pipParams.setIsPlaying(isPlayerPlaying());
380+
if (mCurrentVideoWidth > 0 && mCurrentVideoHeight > 0) {
381+
pipParams.setRadio(mCurrentVideoWidth, mCurrentVideoHeight);
382+
} else {
383+
LiteavLog.e(TAG, "miss video size when enter PIP");
384+
}
385+
pipResult = mPipManager.enterPip(pipParams, new TXPlayerHolder(mLivePlayer, mIsPaused));
386+
// After the startup is successful, pause the video on the current interface.
387+
if (pipResult == FTXEvent.NO_ERROR) {
388+
pausePlayer();
389+
}
378390
}
379391
return TXCommonUtil.intMsgWith((long) pipResult);
380392
}
@@ -532,6 +544,8 @@ public void onVideoResolutionChanged(V2TXLivePlayer player, int width, int heigh
532544
width, height));
533545
int code = TXLiveConstants.PLAY_EVT_CHANGE_RESOLUTION;
534546
mLivePlayer.notifyPlayerEvent(code, bundle);
547+
mLivePlayer.mCurrentVideoWidth = width;
548+
mLivePlayer.mCurrentVideoHeight = height;
535549
}
536550

537551
@Override

FlutterWidget/superplayer_widget/lib/ui/superplayer_widget.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -934,10 +934,8 @@ class FullScreenController {
934934
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: SystemUiOverlay.values);
935935
} else if (orientationDirection == TXVodPlayEvent.ORIENTATION_LANDSCAPE_RIGHT) {
936936
enterFullScreen();
937-
Future.delayed(Duration(milliseconds: 500), (){
938-
SystemChrome.setPreferredOrientations(Platform.isIOS ? [DeviceOrientation.landscapeRight] : [DeviceOrientation.landscapeLeft]);
939-
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
940-
});
937+
SystemChrome.setPreferredOrientations(Platform.isIOS ? [DeviceOrientation.landscapeRight] : [DeviceOrientation.landscapeLeft]);
938+
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
941939
} else if (orientationDirection == TXVodPlayEvent.ORIENTATION_PORTRAIT_DOWN) {
942940
} else if (orientationDirection == TXVodPlayEvent.ORIENTATION_LANDSCAPE_LEFT) {
943941
SystemChrome.setPreferredOrientations(Platform.isIOS ? [DeviceOrientation.landscapeLeft] : [DeviceOrientation.landscapeRight]);

0 commit comments

Comments
 (0)