diff --git a/lib/pages/video/introduction/detail/controller.dart b/lib/pages/video/introduction/detail/controller.dart index 00dba6ffd..bdee2ee17 100644 --- a/lib/pages/video/introduction/detail/controller.dart +++ b/lib/pages/video/introduction/detail/controller.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'dart:convert'; import 'package:PiliPalaX/plugin/pl_player/controller.dart'; import 'package:flutter/material.dart'; @@ -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(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 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)['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 diff --git a/lib/pages/video/view.dart b/lib/pages/video/view.dart index 6702acce5..85e47d852 100644 --- a/lib/pages/video/view.dart +++ b/lib/pages/video/view.dart @@ -350,9 +350,9 @@ class _VideoDetailPageState extends State // 离开当前页面时 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); diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index 1bfc11f66..e80853ec5 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -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, ), ), ),