提交 fc3b1c3e authored 作者: kongdywang's avatar kongdywang

Optimize the timing for calculating video proportions for player components

上级 c931240f
...@@ -184,6 +184,7 @@ class SuperPlayerController { ...@@ -184,6 +184,7 @@ class SuperPlayerController {
break; break;
case TXVodPlayEvent.PLAY_EVT_CHANGE_RESOLUTION: case TXVodPlayEvent.PLAY_EVT_CHANGE_RESOLUTION:
_configVideoSize(event); _configVideoSize(event);
_observer?.onResolutionChanged();
break; break;
} }
}); });
...@@ -232,6 +233,7 @@ class SuperPlayerController { ...@@ -232,6 +233,7 @@ class SuperPlayerController {
break; break;
case TXVodPlayEvent.PLAY_EVT_CHANGE_RESOLUTION: case TXVodPlayEvent.PLAY_EVT_CHANGE_RESOLUTION:
_configVideoSize(event); _configVideoSize(event);
_observer?.onResolutionChanged();
break; break;
} }
}); });
......
...@@ -18,6 +18,7 @@ class _SuperPlayerObserver { ...@@ -18,6 +18,7 @@ class _SuperPlayerObserver {
Function(List<VideoQuality>? qualityList, VideoQuality? defaultQuality) onVideoQualityListChange; Function(List<VideoQuality>? qualityList, VideoQuality? defaultQuality) onVideoQualityListChange;
Function(PlayImageSpriteInfo? info, List<PlayKeyFrameDescInfo>? list) onVideoImageSpriteAndKeyFrameChanged; Function(PlayImageSpriteInfo? info, List<PlayKeyFrameDescInfo>? list) onVideoImageSpriteAndKeyFrameChanged;
Function onRcvFirstIframe; Function onRcvFirstIframe;
Function onResolutionChanged;
Function onSysBackPress; Function onSysBackPress;
Function onPreparePlayVideo; Function onPreparePlayVideo;
Function onDispose; Function onDispose;
...@@ -41,6 +42,7 @@ class _SuperPlayerObserver { ...@@ -41,6 +42,7 @@ class _SuperPlayerObserver {
this.onPlayTimeShiftLive, this.onPlayTimeShiftLive,
this.onVideoQualityListChange, this.onVideoQualityListChange,
this.onVideoImageSpriteAndKeyFrameChanged, this.onVideoImageSpriteAndKeyFrameChanged,
this.onResolutionChanged,
this.onSysBackPress, this.onSysBackPress,
this.onDispose,); this.onDispose,);
} }
...@@ -99,13 +99,7 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs ...@@ -99,13 +99,7 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
() => _playController.playerType == SuperPlayerType.VOD); () => _playController.playerType == SuperPlayerType.VOD);
_playController.onPlayerNetStatusBroadcast.listen((event) { _playController.onPlayerNetStatusBroadcast.listen((event) {
dynamic wd = (event["VIDEO_WIDTH"]); // do nothing
dynamic hd = (event["VIDEO_HEIGHT"]);
if (null != wd && null != hd) {
double w = wd.toDouble();
double h = hd.toDouble();
_calculateSize(w, h);
}
}); });
// only register listen once // only register listen once
_pipSubscription = _pipSubscription =
...@@ -178,8 +172,6 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs ...@@ -178,8 +172,6 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
// onRcvFirstIframe // onRcvFirstIframe
_coverViewKey.currentState?.hideCover(); _coverViewKey.currentState?.hideCover();
_refreshDownloadStatus(); _refreshDownloadStatus();
// After receiving the first frame event, adjust the player size according to the resolution parsed by the player kernel
_calculateSize(_playController.videoWidth, _playController.videoHeight);
}, () { }, () {
// onPlayLoading // onPlayLoading
setState(() { setState(() {
...@@ -218,6 +210,9 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs ...@@ -218,6 +210,9 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
}, (info, list) { }, (info, list) {
// onVideoImageSpriteAndKeyFrameChanged // onVideoImageSpriteAndKeyFrameChanged
_videoBottomKey.currentState?.setKeyFrame(list); _videoBottomKey.currentState?.setKeyFrame(list);
},(){
// onResolutionChanged
_calculateSize(_playController.videoWidth, _playController.videoHeight);
}, () { }, () {
// onSysBackPress // onSysBackPress
_onControlFullScreen(); _onControlFullScreen();
...@@ -347,7 +342,7 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs ...@@ -347,7 +342,7 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
void _calculateSize(double videoWidth, double videoHeight) { void _calculateSize(double videoWidth, double videoHeight) {
if (mounted && (0 != videoWidth && 0 != videoHeight) && if (mounted && (0 != videoWidth && 0 != videoHeight) &&
(_videoWidth != videoWidth && _videoHeight != videoHeight)) { (_videoWidth != videoWidth || _videoHeight != videoHeight)) {
_videoWidth = videoWidth; _videoWidth = videoWidth;
_videoHeight = videoHeight; _videoHeight = videoHeight;
_resizeVideo(); _resizeVideo();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论