Fix auto pip triggering in chat-only mode
This commit is contained in:
parent
c937c4a6fc
commit
f719832f43
2 changed files with 18 additions and 8 deletions
|
|
@ -35,7 +35,8 @@ class _VideoState extends State<Video> with WidgetsBindingObserver {
|
|||
) async {
|
||||
if (Platform.isAndroid &&
|
||||
!await SimplePip.isAutoPipAvailable &&
|
||||
lifecycleState == AppLifecycleState.inactive) {
|
||||
lifecycleState == AppLifecycleState.inactive &&
|
||||
widget.videoStore.settingsStore.showVideo) {
|
||||
widget.videoStore.requestPictureInPicture();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,6 +97,8 @@ abstract class VideoStoreBase with Store {
|
|||
/// Disposes the overlay reactions.
|
||||
late final ReactionDisposer _disposeOverlayReaction;
|
||||
|
||||
ReactionDisposer? _disposeAndroidAutoPipReaction;
|
||||
|
||||
/// If the video is currently paused.
|
||||
///
|
||||
/// Does not pause or play the video, only used for rendering state of the overlay.
|
||||
|
|
@ -148,13 +150,6 @@ abstract class VideoStoreBase with Store {
|
|||
.setMediaPlaybackRequiresUserGesture(false);
|
||||
}
|
||||
|
||||
// On Android, enable auto PiP mode (setAutoEnterEnabled) if the device supports it.
|
||||
if (Platform.isAndroid) {
|
||||
SimplePip.isAutoPipAvailable.then((isAutoPipAvailable) {
|
||||
if (isAutoPipAvailable) pip.setAutoPipMode();
|
||||
});
|
||||
}
|
||||
|
||||
// Initialize the [_overlayTimer] to hide the overlay automatically after 5 seconds.
|
||||
_overlayTimer =
|
||||
Timer(const Duration(seconds: 5), () => _overlayVisible = false);
|
||||
|
|
@ -165,6 +160,19 @@ abstract class VideoStoreBase with Store {
|
|||
(_) => videoWebViewController.loadRequest(Uri.parse(videoUrl)),
|
||||
);
|
||||
|
||||
// On Android, enable auto PiP mode (setAutoEnterEnabled) if the device supports it.
|
||||
if (Platform.isAndroid) {
|
||||
_disposeAndroidAutoPipReaction = autorun(
|
||||
(_) async {
|
||||
if (settingsStore.showVideo && await SimplePip.isAutoPipAvailable) {
|
||||
pip.setAutoPipMode();
|
||||
} else {
|
||||
pip.setAutoPipMode(autoEnter: false);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
updateStreamInfo();
|
||||
}
|
||||
|
||||
|
|
@ -361,5 +369,6 @@ abstract class VideoStoreBase with Store {
|
|||
}
|
||||
|
||||
_disposeOverlayReaction();
|
||||
_disposeAndroidAutoPipReaction?.call();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue