fix(player): iOS自动小窗仅在播放页活跃时拉起
This commit is contained in:
1 parent
85dedf20fa
commit
df2654c9d6
2 files changed
+33
No files matched your search
@@ -133,6 +133,29 @@ class PlayerLogic extends ChangeNotifier {
|
||||
static const _iosAutoPipPrefKey = 'player.ios.autoEnterPip';
|
||||
bool iosAutoPipEnabled = false;
|
||||
|
||||
/// 播放页前台活跃标志:沉浸流切走 tab / 独立页关闭后置 false,
|
||||
/// 此时退后台不再自动拉起画中画(影子只同步不拉起)。
|
||||
bool pipPageActive = false;
|
||||
|
||||
/// 由播放视图同步活跃标志;离开播放页时撤销影子的自动小窗资格,
|
||||
/// 重新进入时重建影子待命(切走期间视图可能被卸载、逻辑实例已换新)。
|
||||
void setPipPageActive(bool active) {
|
||||
debugPrint('pip: page-active -> $active');
|
||||
if (pipPageActive == active) return;
|
||||
pipPageActive = active;
|
||||
if (!active && iosDevice) {
|
||||
unawaited(pictureInPicture.disarmAutoEnter());
|
||||
return;
|
||||
}
|
||||
if (active && iosDevice && iosAutoPipEnabled && !pip) {
|
||||
final episode = trackedEpisode;
|
||||
if (episode != null) {
|
||||
debugPrint('pip: page re-entered, ensure shadow standby');
|
||||
unawaited(_ensureIosShadowStandby(episode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 画中画还原信号:自增通知视频表面回退占位重新等首帧(防回前台黑屏)。
|
||||
int pipResumeToken = 0;
|
||||
|
||||
@@ -925,7 +948,14 @@ class PlayerLogic extends ChangeNotifier {
|
||||
final video = session.active is VideoPlayerPort
|
||||
? session.active as VideoPlayerPort
|
||||
: null;
|
||||
if (state == AppLifecycleState.inactive) {
|
||||
debugPrint(
|
||||
'pip: inactive gate pageActive=$pipPageActive '
|
||||
'video=${video != null} userWantsPlay=${session.userWantsPlay}',
|
||||
);
|
||||
}
|
||||
if (state == AppLifecycleState.inactive &&
|
||||
pipPageActive &&
|
||||
video != null &&
|
||||
session.userWantsPlay) {
|
||||
debugPrint('pip: lifecycle inactive -> arm auto enter');
|
||||
|
||||
Reference in new issue
Block a user