提交 45a843db authored 作者: kongdywang's avatar kongdywang

fix ios translate error & fix play loading ui error

上级 4f5e1ae4
......@@ -187,7 +187,8 @@ SuperPlayerPlugin* instance;
result([TXLiveBase getSDKVersionStr]);
} else if ([@"isDeviceSupportPip" isEqualToString:call.method]) {
BOOL isSupport = [TXVodPlayer isSupportPictureInPicture];
result([NSNumber numberWithBool:isSupport]);
int pipSupportResult = isSupport ? 0 : ERROR_IOS_PIP_DEVICE_NOT_SUPPORT;
result(@(pipSupportResult));
} else if([@"setGlobalEnv" isEqualToString:call.method]) {
NSString *envConfig = call.arguments[@"envConfig"];
int setResult = [TXLiveBase setGlobalEnv:[envConfig UTF8String]];
......
......@@ -43,6 +43,7 @@ class SuperPlayerController {
bool isLoop = false;
bool _needToResume = false;
bool _needToPause = false;
bool callResume = false;
bool _isMultiBitrateStream = false; // 是否是多码流url播放
bool _changeHWAcceleration = false; // 切换硬解后接收到第一个关键帧前的标记位
bool _isOpenHWAcceleration = true;
......@@ -60,10 +61,6 @@ class SuperPlayerController {
double videoHeight = 0;
double currentPlayRate = 1.0;
// 规避IOS部分情况下收不到FirstFrame事件
bool _isCalledFirstFrame = false;
bool _isRecFirstFrameEvent = false;
SuperPlayerController(this._context) {
_initVodPlayer();
_initLivePlayer();
......@@ -99,8 +96,6 @@ class SuperPlayerController {
break;
case TXVodPlayEvent.PLAY_EVT_VOD_PLAY_PREPARED: // vodPrepared
isPrepared = true;
_isRecFirstFrameEvent = false;
_isCalledFirstFrame = false;
if (_isMultiBitrateStream) {
List<dynamic>? bitrateListTemp = await _vodPlayerController.getSupportedBitrates();
List<FTXBitrateItem> bitrateList = [];
......@@ -156,14 +151,13 @@ class SuperPlayerController {
if (_needToPause) {
return;
}
_isRecFirstFrameEvent = true;
if (_changeHWAcceleration) {
LogUtils.d(TAG, "seek pos $_seekPos");
seek(_seekPos);
_changeHWAcceleration = false;
}
_updatePlayerState(SuperPlayerState.PLAYING);
_onRecFirstFrame();
_observer?.onRcvFirstIframe();
break;
case TXVodPlayEvent.PLAY_EVT_PLAY_END:
_updatePlayerState(SuperPlayerState.END);
......@@ -180,13 +174,6 @@ class SuperPlayerController {
if (videoDuration != 0) {
_observer?.onPlayProgress(currentDuration, videoDuration, await getPlayableDuration());
}
if (!_isCalledFirstFrame) {
if (!_isRecFirstFrameEvent) {
_isRecFirstFrameEvent = true;
} else {
_onRecFirstFrame();
}
}
break;
}
});
......@@ -285,9 +272,8 @@ class SuperPlayerController {
await resetPlayer();
if (_playAction == SuperPlayerModel.PLAY_ACTION_AUTO_PLAY || _playAction == SuperPlayerModel.PLAY_ACTION_PRELOAD) {
await _playWithModelInner(videoModel);
} else {
_observer?.onNewVideoPlay();
}
_observer?.onPreparePlayVideo();
}
Future<void> _playWithModelInner(SuperPlayerModel videoModel) async {
......@@ -295,6 +281,7 @@ class SuperPlayerController {
_playAction = videoModel.playAction;
_updateImageSpriteAndKeyFrame(null, null);
_currentProtocol = null;
callResume = false;
// 优先使用url播放
if (videoModel.videoURL.isNotEmpty) {
......@@ -453,13 +440,6 @@ class SuperPlayerController {
}
}
void _onRecFirstFrame() {
if (_isRecFirstFrameEvent) {
_isCalledFirstFrame = true;
_observer?.onRcvFirstIframe();
}
}
/// 暂停视频
/// 涉及到_updatePlayerState相关的方法,不使用异步,避免异步调用导致的playerState更新不及时
void pause() {
......@@ -484,6 +464,7 @@ class SuperPlayerController {
} else {
_livePlayerController.resume();
}
callResume = true;
_needToPause = false;
_updatePlayerState(SuperPlayerState.PLAYING);
}
......
......@@ -19,11 +19,11 @@ class _SuperPlayerObserver {
Function(PlayImageSpriteInfo? info, List<PlayKeyFrameDescInfo>? list) onVideoImageSpriteAndKeyFrameChanged;
Function onRcvFirstIframe;
Function onSysBackPress;
Function onNewVideoPlay;
Function onPreparePlayVideo;
Function onDispose;
_SuperPlayerObserver(
this.onNewVideoPlay,
this.onPreparePlayVideo,
this.onPlayPrepare,
this.onPlayBegin,
this.onPlayPause,
......
......@@ -22,7 +22,7 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
late SuperPlayerController _playController;
bool _isFloatingMode = false;
bool _isPlaying = false;
bool _isLoading = true;
bool _isLoading = false;
bool _isShowCover = true;
double _radioWidth = 0;
......@@ -135,18 +135,16 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
void _registerObserver() {
_playController._observer = _SuperPlayerObserver(() {
// onNewVideoPlay
// preparePlayVideo
setState(() {
_isPlaying = false;
_isShowControlView = false;
_isShowCover = true;
_isLoading = true;
_isLoading = _playController.videoModel!.playAction == SuperPlayerModel.PLAY_ACTION_AUTO_PLAY;
});
_coverViewKey.currentState?.showCover(_playController.videoModel!);
}, () {
// onPlayPrepare
_isShowCover = true;
_coverViewKey.currentState?.showCover(_playController.videoModel!);
_isLoading = true;
_togglePlayUIState(false);
}, (name) {
_togglePlayUIState(true);
......@@ -165,11 +163,16 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
_coverViewKey.currentState?.hideCover();
}, () {
// onPlayLoading
if (!_isPlaying) {
setState(() {
setState(() {
//预加载模式进行特殊处理
if(_playController.videoModel!.playAction == SuperPlayerModel.PLAY_ACTION_PRELOAD) {
if(_playController.callResume) {
_isLoading = true;
}
} else {
_isLoading = true;
});
}
}
});
}, (current, duration, playableDuration) {
// onPlayProgress
_videoBottomKey.currentState?.updateDuration(current, duration, playableDuration);
......@@ -529,7 +532,7 @@ class SuperPlayerViewState extends State<SuperPlayerView> with WidgetsBindingObs
void _onResume() {
SuperPlayerState playerState = _playController.playerState;
int playAction = _playController._playAction;
int playAction = _playController.videoModel!.playAction;
if (playerState == SuperPlayerState.LOADING && playAction == SuperPlayerModel.PLAY_ACTION_PRELOAD) {
_playController.resume();
} else if (playerState == SuperPlayerState.INIT) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论