From e3d561bffd76e4a32d7342f2a2210993dfcf811d Mon Sep 17 00:00:00 2001 From: guozhigq Date: Thu, 24 Aug 2023 14:22:15 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E5=BF=AB=E9=80=9F=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E9=A6=96=E9=A1=B5&=E9=94=80=E6=AF=81=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/video/detail/view.dart | 1 - .../video/detail/widgets/header_control.dart | 8 ++- lib/plugin/pl_player/controller.dart | 55 ++++++++++--------- 3 files changed, 34 insertions(+), 30 deletions(-) diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index 5ece20a8..0d488115 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -97,7 +97,6 @@ class _VideoDetailPageState extends State @override void dispose() { - plPlayerController!.pause(); plPlayerController!.dispose(); super.dispose(); } diff --git a/lib/pages/video/detail/widgets/header_control.dart b/lib/pages/video/detail/widgets/header_control.dart index 58281b69..460f5412 100644 --- a/lib/pages/video/detail/widgets/header_control.dart +++ b/lib/pages/video/detail/widgets/header_control.dart @@ -483,10 +483,12 @@ class _HeaderControlState extends State { size: 15, color: Colors.white, ), - fuc: () { + fuc: () async { // 销毁播放器实例 - widget.controller!.dispose(type: 'all'); - Get.offAll(const MainApp()); + await widget.controller!.dispose(type: 'all'); + if (mounted) { + Navigator.popUntil(context, (route) => route.isFirst); + } }, ), const Spacer(), diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index a72e0df2..33bd7015 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -760,36 +760,39 @@ class PlPlayerController { Future dispose({String type = 'single'}) async { // 每次减1,最后销毁 - if (type == 'single') { + if (type == 'single' && playerCount.value > 1) { _playerCount.value -= 1; _heartDuration = 0; - if (playerCount.value > 0) { - return; - } + pause(); + return; } + _playerCount.value = 0; + try { + _timer?.cancel(); + _timerForVolume?.cancel(); + _timerForGettingVolume?.cancel(); + timerForTrackingMouse?.cancel(); + _timerForSeek?.cancel(); + videoFitChangedTimer?.cancel(); + // _position.close(); + _playerEventSubs?.cancel(); + // _sliderPosition.close(); + // _sliderTempPosition.close(); + // _isSliderMoving.close(); + // _duration.close(); + // _buffered.close(); + // _showControls.close(); + // _controlsLock.close(); - _timer?.cancel(); - _timerForVolume?.cancel(); - _timerForGettingVolume?.cancel(); - timerForTrackingMouse?.cancel(); - _timerForSeek?.cancel(); - videoFitChangedTimer?.cancel(); - _position.close(); - _playerEventSubs?.cancel(); - _sliderPosition.close(); - _sliderTempPosition.close(); - _isSliderMoving.close(); - _duration.close(); - _buffered.close(); - _showControls.close(); - _controlsLock.close(); + // playerStatus.status.close(); + // dataStatus.status.close(); - playerStatus.status.close(); - dataStatus.status.close(); - - removeListeners(); - await _videoPlayerController?.dispose(); - _videoPlayerController = null; - _instance = null; + removeListeners(); + await _videoPlayerController?.dispose(); + _videoPlayerController = null; + _instance = null; + } catch (err) { + print(err); + } } } From 6461f72b5e68929a8b543b2be3b63c82de59318d Mon Sep 17 00:00:00 2001 From: guozhigq Date: Thu, 24 Aug 2023 15:24:56 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20#28=20=E5=90=88=E9=9B=86=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=B8=B2=E6=9F=93=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../detail/introduction/widgets/season.dart | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/pages/video/detail/introduction/widgets/season.dart b/lib/pages/video/detail/introduction/widgets/season.dart index 876dac74..3f3a1475 100644 --- a/lib/pages/video/detail/introduction/widgets/season.dart +++ b/lib/pages/video/detail/introduction/widgets/season.dart @@ -28,7 +28,25 @@ class _SeasonPanelState extends State { @override void initState() { super.initState(); - episodes = widget.ugcSeason.sections!.first.episodes!; + + /// 根据 cid 找到对应集,找到对应 episodes + /// 有多个episodes时,只显示其中一个 + /// TODO 同时显示多个合集 + List sections = widget.ugcSeason.sections!; + for (int i = 0; i < sections.length; i++) { + List episodesList = sections[i].episodes!; + for (int j = 0; j < episodesList.length; j++) { + if (episodesList[j].cid == widget.cid) { + episodes = episodesList; + continue; + } + } + } + + /// 取对应 season_id 的 episodes + // episodes = widget.ugcSeason.sections! + // .firstWhere((e) => e.seasonId == widget.ugcSeason.id) + // .episodes!; currentIndex = episodes.indexWhere((e) => e.cid == widget.cid); } @@ -136,7 +154,7 @@ class _SeasonPanelState extends State { ), const SizedBox(width: 10), Text( - '${currentIndex + 1}/${widget.ugcSeason.epCount}', + '${currentIndex + 1}/${episodes.length}', style: Theme.of(context).textTheme.labelMedium, ), const SizedBox(width: 6),