mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
@@ -309,7 +309,12 @@ class PlPlayerController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
late bool shouldSetPip = false;
|
late bool _shouldSetPip = false;
|
||||||
|
bool get _isVideoPage {
|
||||||
|
final currentRoute = Get.currentRoute;
|
||||||
|
return currentRoute.startsWith('/video') ||
|
||||||
|
currentRoute.startsWith('/liveRoom');
|
||||||
|
}
|
||||||
|
|
||||||
void enterPip({bool isAuto = false}) {
|
void enterPip({bool isAuto = false}) {
|
||||||
if (videoController != null) {
|
if (videoController != null) {
|
||||||
@@ -323,7 +328,7 @@ class PlPlayerController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void disableAutoEnterPip() {
|
void disableAutoEnterPip() {
|
||||||
if (shouldSetPip) {
|
if (_shouldSetPip) {
|
||||||
Utils.channel.invokeMethod('setPipAutoEnterEnabled', {
|
Utils.channel.invokeMethod('setPipAutoEnterEnabled', {
|
||||||
'autoEnable': false,
|
'autoEnable': false,
|
||||||
});
|
});
|
||||||
@@ -571,14 +576,13 @@ class PlPlayerController {
|
|||||||
if (sdkInt < 31) {
|
if (sdkInt < 31) {
|
||||||
Utils.channel.setMethodCallHandler((call) async {
|
Utils.channel.setMethodCallHandler((call) async {
|
||||||
if (call.method == 'onUserLeaveHint') {
|
if (call.method == 'onUserLeaveHint') {
|
||||||
if (playerStatus.playing &&
|
if (playerStatus.playing && _isVideoPage) {
|
||||||
Get.currentRoute.startsWith('/video')) {
|
|
||||||
enterPip();
|
enterPip();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
shouldSetPip = true;
|
_shouldSetPip = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1020,8 +1024,12 @@ class PlPlayerController {
|
|||||||
subscriptions = {
|
subscriptions = {
|
||||||
videoPlayerController!.stream.playing.listen((event) {
|
videoPlayerController!.stream.playing.listen((event) {
|
||||||
if (event) {
|
if (event) {
|
||||||
if (shouldSetPip) {
|
if (_shouldSetPip) {
|
||||||
enterPip(isAuto: true);
|
if (_isVideoPage) {
|
||||||
|
enterPip(isAuto: true);
|
||||||
|
} else {
|
||||||
|
disableAutoEnterPip();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
playerStatus.status.value = PlayerStatus.playing;
|
playerStatus.status.value = PlayerStatus.playing;
|
||||||
} else {
|
} else {
|
||||||
@@ -1712,9 +1720,7 @@ class PlPlayerController {
|
|||||||
if (!isCloseAll && _playerCount > 1) {
|
if (!isCloseAll && _playerCount > 1) {
|
||||||
_playerCount -= 1;
|
_playerCount -= 1;
|
||||||
_heartDuration = 0;
|
_heartDuration = 0;
|
||||||
final previousRoute = Get.previousRoute;
|
if (!_isVideoPage) {
|
||||||
if (!previousRoute.startsWith('/video') &&
|
|
||||||
!previousRoute.startsWith('/liveRoom')) {
|
|
||||||
disableAutoEnterPip();
|
disableAutoEnterPip();
|
||||||
pause();
|
pause();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user