提交 99bf1581 authored 作者: kongdywang's avatar kongdywang

Optimize the timing for calculating video proportions for player components

上级 837b09c7
......@@ -184,6 +184,7 @@ class SuperPlayerController {
break;
case TXVodPlayEvent.PLAY_EVT_CHANGE_RESOLUTION:
_configVideoSize(event);
_observer?.onResolutionChanged();
break;
}
});
......@@ -232,6 +233,7 @@ class SuperPlayerController {
break;
case TXVodPlayEvent.PLAY_EVT_CHANGE_RESOLUTION:
_configVideoSize(event);
_observer?.onResolutionChanged();
break;
}
});
......
......@@ -18,6 +18,7 @@ class _SuperPlayerObserver {
Function(List<VideoQuality>? qualityList, VideoQuality? defaultQuality) onVideoQualityListChange;
Function(PlayImageSpriteInfo? info, List<PlayKeyFrameDescInfo>? list) onVideoImageSpriteAndKeyFrameChanged;
Function onRcvFirstIframe;
Function onResolutionChanged;
Function onSysBackPress;
Function onPreparePlayVideo;
Function onDispose;
......@@ -41,6 +42,7 @@ class _SuperPlayerObserver {
this.onPlayTimeShiftLive,
this.onVideoQualityListChange,
this.onVideoImageSpriteAndKeyFrameChanged,
this.onResolutionChanged,
this.onSysBackPress,
this.onDispose,);
}
......@@ -99,13 +99,7 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
() => _playController.playerType == SuperPlayerType.VOD);
_playController.onPlayerNetStatusBroadcast.listen((event) {
dynamic wd = (event["VIDEO_WIDTH"]);
dynamic hd = (event["VIDEO_HEIGHT"]);
if (null != wd && null != hd) {
double w = wd.toDouble();
double h = hd.toDouble();
_calculateSize(w, h);
}
// do nothing
});
// only register listen once
_pipSubscription = SuperPlayerPlugin.instance.onExtraEventBroadcast.listen((event) {
......@@ -176,8 +170,6 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
// onRcvFirstIframe
_coverViewKey.currentState?.hideCover();
_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
setState(() {
......@@ -216,6 +208,9 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
}, (info, list) {
// onVideoImageSpriteAndKeyFrameChanged
_videoBottomKey.currentState?.setKeyFrame(list);
},(){
// onResolutionChanged
_calculateSize(_playController.videoWidth, _playController.videoHeight);
}, () {
// onSysBackPress
_onControlFullScreen();
......@@ -345,7 +340,7 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
void _calculateSize(double videoWidth, double videoHeight) {
if (mounted && (0 != videoWidth && 0 != videoHeight) &&
(_videoWidth != videoWidth && _videoHeight != videoHeight)) {
(_videoWidth != videoWidth || _videoHeight != videoHeight)) {
_videoWidth = videoWidth;
_videoHeight = videoHeight;
_resizeVideo();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论