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

fix ios translate error & fix play loading ui error

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