mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
fix: 点进推荐或手动播放产生全屏故障、状态栏跳动;多层推荐性能
This commit is contained in:
@@ -23,7 +23,6 @@ import 'package:PiliPalaX/plugin/pl_player/index.dart';
|
|||||||
import 'package:PiliPalaX/plugin/pl_player/models/play_repeat.dart';
|
import 'package:PiliPalaX/plugin/pl_player/models/play_repeat.dart';
|
||||||
import 'package:PiliPalaX/services/service_locator.dart';
|
import 'package:PiliPalaX/services/service_locator.dart';
|
||||||
import 'package:PiliPalaX/utils/storage.dart';
|
import 'package:PiliPalaX/utils/storage.dart';
|
||||||
import 'package:status_bar_control/status_bar_control.dart';
|
|
||||||
|
|
||||||
import '../../../services/shutdown_timer_service.dart';
|
import '../../../services/shutdown_timer_service.dart';
|
||||||
import 'widgets/header_control.dart';
|
import 'widgets/header_control.dart';
|
||||||
@@ -64,6 +63,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
late final AppLifecycleListener _lifecycleListener;
|
late final AppLifecycleListener _lifecycleListener;
|
||||||
bool isShowing = true;
|
bool isShowing = true;
|
||||||
RxBool isFullScreen = false.obs;
|
RxBool isFullScreen = false.obs;
|
||||||
|
late StreamSubscription<bool> fullScreenStatusListener;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -95,7 +95,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
videoSourceInit();
|
videoSourceInit();
|
||||||
appbarStreamListen();
|
appbarStreamListen();
|
||||||
lifecycleListener();
|
lifecycleListener();
|
||||||
fullScreenStatusListener();
|
|
||||||
autoScreen();
|
autoScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,6 +104,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
if (videoDetailController.autoPlay.value) {
|
if (videoDetailController.autoPlay.value) {
|
||||||
plPlayerController = videoDetailController.plPlayerController;
|
plPlayerController = videoDetailController.plPlayerController;
|
||||||
plPlayerController!.addStatusLister(playerListener);
|
plPlayerController!.addStatusLister(playerListener);
|
||||||
|
listenFullScreenStatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,13 +140,13 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
plPlayerController!.play();
|
plPlayerController!.play();
|
||||||
}
|
}
|
||||||
// 播放完展示控制栏
|
// 播放完展示控制栏
|
||||||
try {
|
if (videoDetailController.floating != null) {
|
||||||
PiPStatus currentStatus =
|
PiPStatus currentStatus =
|
||||||
await videoDetailController.floating!.pipStatus;
|
await videoDetailController.floating!.pipStatus;
|
||||||
if (currentStatus == PiPStatus.disabled) {
|
if (currentStatus == PiPStatus.disabled) {
|
||||||
plPlayerController!.onLockControl(false);
|
plPlayerController!.onLockControl(false);
|
||||||
}
|
}
|
||||||
} catch (_) {}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,6 +160,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
await videoDetailController.playerInit();
|
await videoDetailController.playerInit();
|
||||||
plPlayerController = videoDetailController.plPlayerController;
|
plPlayerController = videoDetailController.plPlayerController;
|
||||||
plPlayerController!.addStatusLister(playerListener);
|
plPlayerController!.addStatusLister(playerListener);
|
||||||
|
listenFullScreenStatus();
|
||||||
videoDetailController.autoPlay.value = true;
|
videoDetailController.autoPlay.value = true;
|
||||||
videoDetailController.isShowCover.value = false;
|
videoDetailController.isShowCover.value = false;
|
||||||
}
|
}
|
||||||
@@ -185,17 +186,18 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fullScreenStatusListener() {
|
void listenFullScreenStatus() {
|
||||||
plPlayerController?.isFullScreen.listen((bool isFullScreen) {
|
fullScreenStatusListener =
|
||||||
if (isFullScreen) {
|
plPlayerController!.isFullScreen.listen((bool status) {
|
||||||
|
if (status) {
|
||||||
videoDetailController.hiddenReplyReplyPanel();
|
videoDetailController.hiddenReplyReplyPanel();
|
||||||
enterFullScreen();
|
hideStatusBar();
|
||||||
}
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
this.isFullScreen.value = isFullScreen;
|
isFullScreen.value = status;
|
||||||
});
|
});
|
||||||
if (!isFullScreen) {
|
if (!status) {
|
||||||
exitFullScreen();
|
showStatusBar();
|
||||||
if (setting.get(SettingBoxKey.horizontalScreen, defaultValue: false)) {
|
if (setting.get(SettingBoxKey.horizontalScreen, defaultValue: false)) {
|
||||||
autoScreen();
|
autoScreen();
|
||||||
} else {
|
} else {
|
||||||
@@ -213,6 +215,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
shutdownTimerService.handleWaitingFinished();
|
shutdownTimerService.handleWaitingFinished();
|
||||||
if (plPlayerController != null) {
|
if (plPlayerController != null) {
|
||||||
plPlayerController!.removeStatusLister(playerListener);
|
plPlayerController!.removeStatusLister(playerListener);
|
||||||
|
fullScreenStatusListener.cancel();
|
||||||
plPlayerController!.dispose();
|
plPlayerController!.dispose();
|
||||||
}
|
}
|
||||||
if (videoDetailController.floating != null) {
|
if (videoDetailController.floating != null) {
|
||||||
@@ -221,8 +224,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
videoPlayerServiceHandler.onVideoDetailDispose();
|
videoPlayerServiceHandler.onVideoDetailDispose();
|
||||||
floating.dispose();
|
floating.dispose();
|
||||||
_lifecycleListener.dispose();
|
_lifecycleListener.dispose();
|
||||||
StatusBarControl.setHidden(false, animation: StatusBarAnimation.FADE);
|
showStatusBar();
|
||||||
exitFullScreen();
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,6 +240,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
videoDetailController.defaultST = plPlayerController!.position.value;
|
videoDetailController.defaultST = plPlayerController!.position.value;
|
||||||
videoIntroController.isPaused = true;
|
videoIntroController.isPaused = true;
|
||||||
plPlayerController!.removeStatusLister(playerListener);
|
plPlayerController!.removeStatusLister(playerListener);
|
||||||
|
fullScreenStatusListener.cancel();
|
||||||
plPlayerController!.pause();
|
plPlayerController!.pause();
|
||||||
}
|
}
|
||||||
setState(() => isShowing = false);
|
setState(() => isShowing = false);
|
||||||
@@ -247,10 +250,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
@override
|
@override
|
||||||
// 返回当前页面时
|
// 返回当前页面时
|
||||||
void didPopNext() async {
|
void didPopNext() async {
|
||||||
if (plPlayerController != null &&
|
|
||||||
plPlayerController!.videoPlayerController != null) {
|
|
||||||
setState(() => isShowing = true);
|
|
||||||
}
|
|
||||||
videoDetailController.isFirstTime = false;
|
videoDetailController.isFirstTime = false;
|
||||||
final bool autoplay = autoPlayEnable;
|
final bool autoplay = autoPlayEnable;
|
||||||
videoDetailController.playerInit(autoplay: autoplay);
|
videoDetailController.playerInit(autoplay: autoplay);
|
||||||
@@ -265,6 +264,10 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
plPlayerController?.play();
|
plPlayerController?.play();
|
||||||
}
|
}
|
||||||
plPlayerController?.addStatusLister(playerListener);
|
plPlayerController?.addStatusLister(playerListener);
|
||||||
|
if (plPlayerController != null) {
|
||||||
|
listenFullScreenStatus();
|
||||||
|
}
|
||||||
|
setState(() => isShowing = true);
|
||||||
super.didPopNext();
|
super.didPopNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,8 +291,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
|
|
||||||
void autoEnterPip() {
|
void autoEnterPip() {
|
||||||
final String routePath = Get.currentRoute;
|
final String routePath = Get.currentRoute;
|
||||||
final bool isPortrait =
|
|
||||||
MediaQuery.of(context).orientation == Orientation.portrait;
|
|
||||||
|
|
||||||
if (autoPiP && routePath.startsWith('/video')) {
|
if (autoPiP && routePath.startsWith('/video')) {
|
||||||
floating.enable(
|
floating.enable(
|
||||||
@@ -340,7 +341,10 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
: videoheight,
|
: videoheight,
|
||||||
width: MediaQuery.of(context).size.width,
|
width: MediaQuery.of(context).size.width,
|
||||||
child: PopScope(
|
child: PopScope(
|
||||||
canPop: isFullScreen.value != true,
|
canPop: isFullScreen.value != true &&
|
||||||
|
(horizontalScreen ||
|
||||||
|
MediaQuery.of(context).orientation ==
|
||||||
|
Orientation.portrait),
|
||||||
onPopInvoked: (bool didPop) {
|
onPopInvoked: (bool didPop) {
|
||||||
if (isFullScreen.value == true) {
|
if (isFullScreen.value == true) {
|
||||||
plPlayerController!
|
plPlayerController!
|
||||||
@@ -519,34 +523,30 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
child: TabBarView(
|
child: TabBarView(
|
||||||
controller: videoDetailController.tabCtr,
|
controller: videoDetailController.tabCtr,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Builder(
|
CustomScrollView(
|
||||||
builder: (BuildContext context) {
|
key: const PageStorageKey<String>('简介'),
|
||||||
return CustomScrollView(
|
slivers: <Widget>[
|
||||||
key: const PageStorageKey<String>('简介'),
|
if (videoDetailController.videoType ==
|
||||||
slivers: <Widget>[
|
SearchType.video) ...[
|
||||||
if (videoDetailController.videoType ==
|
const VideoIntroPanel(),
|
||||||
SearchType.video) ...[
|
] else if (videoDetailController
|
||||||
const VideoIntroPanel(),
|
.videoType ==
|
||||||
] else if (videoDetailController
|
SearchType.media_bangumi) ...[
|
||||||
.videoType ==
|
Obx(() => BangumiIntroPanel(
|
||||||
SearchType.media_bangumi) ...[
|
cid:
|
||||||
Obx(() => BangumiIntroPanel(
|
videoDetailController.cid.value)),
|
||||||
cid: videoDetailController
|
],
|
||||||
.cid.value)),
|
SliverToBoxAdapter(
|
||||||
],
|
child: Divider(
|
||||||
SliverToBoxAdapter(
|
indent: 12,
|
||||||
child: Divider(
|
endIndent: 12,
|
||||||
indent: 12,
|
color: Theme.of(context)
|
||||||
endIndent: 12,
|
.dividerColor
|
||||||
color: Theme.of(context)
|
.withOpacity(0.06),
|
||||||
.dividerColor
|
),
|
||||||
.withOpacity(0.06),
|
),
|
||||||
),
|
const RelatedVideoPanel(),
|
||||||
),
|
],
|
||||||
const RelatedVideoPanel(),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
Obx(
|
Obx(
|
||||||
() => VideoReplyPanel(
|
() => VideoReplyPanel(
|
||||||
@@ -799,54 +799,31 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
|||||||
);
|
);
|
||||||
}))
|
}))
|
||||||
]));
|
]));
|
||||||
Widget childWhenEnabled = FutureBuilder(
|
Widget childWhenEnabled = Obx(
|
||||||
key: Key(heroTag),
|
() => !videoDetailController.autoPlay.value
|
||||||
future: _futureBuilderFuture,
|
? const SizedBox()
|
||||||
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
: PLVideoPlayer(
|
||||||
if (snapshot.hasData && snapshot.data['status']) {
|
controller: plPlayerController!,
|
||||||
return Obx(
|
headerControl: HeaderControl(
|
||||||
() => !videoDetailController.autoPlay.value
|
controller: plPlayerController,
|
||||||
? const SizedBox()
|
videoDetailCtr: videoDetailController,
|
||||||
: PLVideoPlayer(
|
),
|
||||||
controller: plPlayerController!,
|
),
|
||||||
headerControl: HeaderControl(
|
|
||||||
controller: plPlayerController,
|
|
||||||
videoDetailCtr: videoDetailController,
|
|
||||||
),
|
|
||||||
// danmuWidget: Obx(
|
|
||||||
// () => PlDanmaku(
|
|
||||||
// key: Key(
|
|
||||||
// videoDetailController.danmakuCid.value.toString()),
|
|
||||||
// cid: videoDetailController.danmakuCid.value,
|
|
||||||
// playerController: plPlayerController!,
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
// if (!horizontalScreen) {
|
|
||||||
// if (Platform.isAndroid) {
|
|
||||||
// return PiPSwitcher(
|
|
||||||
// childWhenEnabled: childWhenEnabled,
|
|
||||||
// childWhenDisabled: childWhenDisabled,
|
|
||||||
// floating: floating,);
|
|
||||||
// }
|
|
||||||
// return childWhenDisabled;
|
|
||||||
// }
|
|
||||||
return OrientationBuilder(
|
return OrientationBuilder(
|
||||||
builder: (BuildContext context, Orientation orientation) {
|
builder: (BuildContext context, Orientation orientation) {
|
||||||
print("orientation $orientation");
|
if (!isShowing) {
|
||||||
|
return const SizedBox();
|
||||||
|
}
|
||||||
if (orientation == Orientation.landscape) {
|
if (orientation == Orientation.landscape) {
|
||||||
enterFullScreen();
|
|
||||||
if (!horizontalScreen) {
|
if (!horizontalScreen) {
|
||||||
|
hideStatusBar();
|
||||||
videoDetailController.hiddenReplyReplyPanel();
|
videoDetailController.hiddenReplyReplyPanel();
|
||||||
}
|
}
|
||||||
} else if (!isFullScreen.value) {
|
} else {
|
||||||
StatusBarControl.setHidden(false, animation: StatusBarAnimation.FADE);
|
if (!isFullScreen.value) {
|
||||||
|
showStatusBar();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (Platform.isAndroid) {
|
if (Platform.isAndroid) {
|
||||||
return PiPSwitcher(
|
return PiPSwitcher(
|
||||||
|
|||||||
@@ -1078,9 +1078,7 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
!setting.get(SettingBoxKey.horizontalScreen,
|
!setting.get(SettingBoxKey.horizontalScreen,
|
||||||
defaultValue: false))
|
defaultValue: false))
|
||||||
{
|
{
|
||||||
SystemChrome.setPreferredOrientations([
|
verticalScreen(),
|
||||||
DeviceOrientation.portraitUp,
|
|
||||||
])
|
|
||||||
},
|
},
|
||||||
Get.back()
|
Get.back()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import 'package:PiliPalaX/services/service_locator.dart';
|
|||||||
import 'package:PiliPalaX/utils/feed_back.dart';
|
import 'package:PiliPalaX/utils/feed_back.dart';
|
||||||
import 'package:PiliPalaX/utils/storage.dart';
|
import 'package:PiliPalaX/utils/storage.dart';
|
||||||
import 'package:screen_brightness/screen_brightness.dart';
|
import 'package:screen_brightness/screen_brightness.dart';
|
||||||
import 'package:status_bar_control/status_bar_control.dart';
|
|
||||||
import 'package:universal_platform/universal_platform.dart';
|
import 'package:universal_platform/universal_platform.dart';
|
||||||
// import 'package:wakelock_plus/wakelock_plus.dart';
|
// import 'package:wakelock_plus/wakelock_plus.dart';
|
||||||
|
|
||||||
@@ -943,12 +942,11 @@ class PlPlayerController {
|
|||||||
// 全屏
|
// 全屏
|
||||||
Future<void> triggerFullScreen({bool status = true}) async {
|
Future<void> triggerFullScreen({bool status = true}) async {
|
||||||
if (!isFullScreen.value && status) {
|
if (!isFullScreen.value && status) {
|
||||||
await StatusBarControl.setHidden(true, animation: StatusBarAnimation.FADE);
|
// StatusBarControl.setHidden(true, animation: StatusBarAnimation.FADE);
|
||||||
|
hideStatusBar();
|
||||||
/// 按照视频宽高比决定全屏方向
|
/// 按照视频宽高比决定全屏方向
|
||||||
toggleFullScreen(true);
|
toggleFullScreen(true);
|
||||||
|
|
||||||
/// 进入全屏
|
/// 进入全屏
|
||||||
await enterFullScreen();
|
|
||||||
FullScreenMode mode = FullScreenModeCode.fromCode(
|
FullScreenMode mode = FullScreenModeCode.fromCode(
|
||||||
setting.get(SettingBoxKey.fullScreenMode, defaultValue: 0))!;
|
setting.get(SettingBoxKey.fullScreenMode, defaultValue: 0))!;
|
||||||
if (mode == FullScreenMode.vertical ||
|
if (mode == FullScreenMode.vertical ||
|
||||||
@@ -960,15 +958,13 @@ class PlPlayerController {
|
|||||||
} else {
|
} else {
|
||||||
await landScape();
|
await landScape();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (isFullScreen.value && !status) {
|
} else if (isFullScreen.value && !status) {
|
||||||
if (!setting.get(SettingBoxKey.horizontalScreen, defaultValue: false)) {
|
// StatusBarControl.setHidden(false, animation: StatusBarAnimation.FADE);
|
||||||
StatusBarControl.setHidden(false, animation: StatusBarAnimation.FADE);
|
showStatusBar();
|
||||||
// Get.back();
|
|
||||||
// await verticalScreen();
|
|
||||||
}
|
|
||||||
exitFullScreen();
|
|
||||||
toggleFullScreen(false);
|
toggleFullScreen(false);
|
||||||
|
if (!setting.get(SettingBoxKey.horizontalScreen, defaultValue: false)){
|
||||||
|
await verticalScreen();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,14 +53,14 @@ Future<void> autoScreen() async {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> enterFullScreen() async {
|
Future<void> hideStatusBar() async {
|
||||||
await SystemChrome.setEnabledSystemUIMode(
|
await SystemChrome.setEnabledSystemUIMode(
|
||||||
SystemUiMode.immersiveSticky,
|
SystemUiMode.immersiveSticky,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//退出全屏显示
|
//退出全屏显示
|
||||||
Future<void> exitFullScreen() async {
|
Future<void> showStatusBar() async {
|
||||||
dynamic document;
|
dynamic document;
|
||||||
late SystemUiMode mode = SystemUiMode.edgeToEdge;
|
late SystemUiMode mode = SystemUiMode.edgeToEdge;
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user