Skip to content

Commit

Permalink
feat: 优化返回播放详情页体验
Browse files Browse the repository at this point in the history
  • Loading branch information
orz12 committed Jan 14, 2025
1 parent c788023 commit 179617f
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 32 deletions.
43 changes: 41 additions & 2 deletions lib/pages/video/introduction/detail/controller.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:convert';

import 'package:PiliPalaX/plugin/pl_player/controller.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -138,8 +139,46 @@ class VideoIntroController extends GetxController {
}

void openVideoDetail() {
Get.toNamed('/video?bvid=$bvid&cid=${lastPlayCid.value}&resume=true',
arguments: {'heroTag': heroTag});
// if (Get.previousRoute == '/video?bvid=$bvid&cid=${lastPlayCid.value}') {
// Get.back();
// return;
// }

VideoDetailController? videoDetailCtr;
try {
videoDetailCtr = Get.find<VideoDetailController>(tag: heroTag);
} catch (_) {}
print("videoDetailCtr: $videoDetailCtr");
if (videoDetailCtr == null) {
Get.toNamed('/video?bvid=$bvid&cid=${lastPlayCid.value}&resume=true',
arguments: {'heroTag': heroTag});
return;
}
videoDetailCtr.resumePlay = true;
popRouteStackContinuously = '/video?bvid=$bvid&cid=${lastPlayCid.value}';
Get.until((Route<dynamic> route) {
print(route.settings.name);
print(route.settings.arguments);
print(route.settings.arguments.runtimeType);
if (route.settings.arguments is Map) {
String? heroTagCurr =
(route.settings.arguments as Map<String, dynamic>)['heroTag'];
if (heroTagCurr != null && heroTagCurr.isNotEmpty) {
return heroTag == heroTagCurr;
}
}
// String? args = route.settings.arguments?.toString();
// if (args != null && args.isNotEmpty) {
// String? heroTagCurr =jsonDecode(args)['heroTag'];
// if (heroTagCurr != null && heroTagCurr.isNotEmpty) {
// return heroTag == heroTagCurr;
// }
// }
// return route.settings.arguments!.heroTag == heroTag || route.isFirst;
return route.settings.name?.startsWith('/video?bvid=$bvid') == true ||
route.isFirst;
});
popRouteStackContinuously = "";
}

// 获取视频简介&分p
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/video/view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,9 @@ class _VideoDetailPageState extends State<VideoDetailPage>
// 离开当前页面时
void didPushNext() async {
// _bufferedListener?.cancel();
videoDetailController.defaultST = plPlayerController!.position.value;
if (!triggerFloatingWindowWhenLeaving() &&
!floatingManager.containsFloating(globalId)) {
videoDetailController.defaultST = plPlayerController!.position.value;
videoIntroController.isPaused = true;
plPlayerController!.pause();
plPlayerController!.removeStatusLister(playerListener);
Expand Down
55 changes: 26 additions & 29 deletions lib/plugin/pl_player/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1338,35 +1338,32 @@ class PlPlayerController {
height: floatingHeight,
child: Column(
children: [
Hero(
tag: heroTag,
child: SizedBox(
width: floatingWidth,
height: floatingHeight - extentHeight,
child: InkWell(
onTap: () {
if (videoIntroController != null) {
videoIntroController.openVideoDetail();
} else if (bangumiIntroController != null) {
bangumiIntroController.openVideoDetail();
} else {
pauseIfExists();
}
floatingManager.closeFloating(globalId);
},
child: Video(
controller: videoController!,
controls: NoVideoControls,
pauseUponEnteringBackgroundMode:
!_continuePlayInBackground.value,
resumeUponEnteringForegroundMode: true,
// 字幕尺寸调节
subtitleViewConfiguration: SubtitleViewConfiguration(
style: subtitleStyle.value,
padding:
EdgeInsets.only(bottom: subtitleBottomPadding.value)),
fit: BoxFit.contain,
),
SizedBox(
width: floatingWidth,
height: floatingHeight - extentHeight,
child: InkWell(
onTap: () {
if (videoIntroController != null) {
videoIntroController.openVideoDetail();
} else if (bangumiIntroController != null) {
bangumiIntroController.openVideoDetail();
} else {
pauseIfExists();
}
floatingManager.closeFloating(globalId);
},
child: Video(
controller: videoController!,
controls: NoVideoControls,
pauseUponEnteringBackgroundMode:
!_continuePlayInBackground.value,
resumeUponEnteringForegroundMode: true,
// 字幕尺寸调节
subtitleViewConfiguration: SubtitleViewConfiguration(
style: subtitleStyle.value,
padding:
EdgeInsets.only(bottom: subtitleBottomPadding.value)),
fit: BoxFit.contain,
),
),
),
Expand Down

0 comments on commit 179617f

Please sign in to comment.