Fix pip exception on Android (#232)

This commit is contained in:
Tommy Chow 2023-01-26 22:20:02 -05:00 • committed by GitHub
parent 1caae18148
commit 8f8bb1ae28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -232,7 +232,11 @@ abstract class VideoStoreBase with Store {
@action
void dispose() {
// Disable auto PiP when leaving so that we don't enter PiP on other screens.
if (Platform.isAndroid) pip.setAutoPipMode(autoEnter: false);
if (Platform.isAndroid) {
SimplePip.isAutoPipAvailable.then((isAutoPipAvailable) {
if (isAutoPipAvailable) pip.setAutoPipMode(autoEnter: false);
});
}
// Not ideal, but seems like the only way of disposing of the video properly.
// Will both prevent the video from continuing to play when dismissed and closes PiP on iOS.