diff --git a/lib/pages/bangumi/introduction/controller.dart b/lib/pages/bangumi/introduction/controller.dart index 841e83b7..a76de744 100644 --- a/lib/pages/bangumi/introduction/controller.dart +++ b/lib/pages/bangumi/introduction/controller.dart @@ -15,6 +15,7 @@ import 'package:PiliPalaX/utils/feed_back.dart'; import 'package:PiliPalaX/utils/id_utils.dart'; import 'package:PiliPalaX/utils/storage.dart'; import 'package:share_plus/share_plus.dart'; +import 'package:url_launcher/url_launcher.dart'; class BangumiIntroController extends GetxController { // 视频bvid @@ -237,7 +238,7 @@ class BangumiIntroController extends GetxController { builder: (context) { String videoUrl = '${HttpString.baseUrl}/video/$bvid'; return AlertDialog( - title: const Text('分享方式'), + title: const Text('请选择'), actions: [ TextButton( onPressed: () { @@ -245,6 +246,11 @@ class BangumiIntroController extends GetxController { SmartDialog.showToast('已复制'); }, child: const Text('复制链接到剪贴板')), + TextButton( + onPressed: () { + launchUrl(Uri.parse(videoUrl)); + }, + child: const Text('其它app打开')), TextButton( onPressed: () async { var result = @@ -340,22 +346,29 @@ class BangumiIntroController extends GetxController { return true; } - /// 列表循环或者顺序播放时,自动播放下一个 + /// 列表循环或者顺序播放时,自动播放下一个;自动连播时,播放相关视频 bool nextPlay() { late List episodes; - if (bangumiDetail.value.episodes != null) { - episodes = bangumiDetail.value.episodes!; - } VideoDetailController videoDetailCtr = Get.find(tag: Get.arguments['heroTag']); + PlayRepeat platRepeat = videoDetailCtr.plPlayerController.playRepeat; + + if (bangumiDetail.value.episodes != null) { + episodes = bangumiDetail.value.episodes!; + } else { + if (platRepeat == PlayRepeat.autoPlayRelated) { + return playRelated(); + } + } int currentIndex = episodes.indexWhere((e) => e.cid == videoDetailCtr.cid.value); int nextIndex = currentIndex + 1; - PlayRepeat platRepeat = videoDetailCtr.plPlayerController.playRepeat; // 列表循环 if (nextIndex == episodes.length - 1) { if (platRepeat == PlayRepeat.listCycle) { nextIndex = 0; + } else if (platRepeat == PlayRepeat.autoPlayRelated) { + return playRelated(); } else { return false; } @@ -366,4 +379,9 @@ class BangumiIntroController extends GetxController { changeSeasonOrbangu(bvid, cid, aid); return true; } + + bool playRelated() { + SmartDialog.showToast('番剧暂无相关视频'); + return false; + } } diff --git a/lib/pages/video/detail/introduction/controller.dart b/lib/pages/video/detail/introduction/controller.dart index 9666fe2a..9627e669 100644 --- a/lib/pages/video/detail/introduction/controller.dart +++ b/lib/pages/video/detail/introduction/controller.dart @@ -19,7 +19,10 @@ import 'package:PiliPalaX/utils/id_utils.dart'; import 'package:PiliPalaX/utils/storage.dart'; import 'package:share_plus/share_plus.dart'; import 'package:PiliPalaX/pages/member/controller.dart'; +import 'package:url_launcher/url_launcher.dart'; +import '../../../../http/search.dart'; +import '../../../../models/model_hot_video_item.dart'; import '../related/index.dart'; import 'widgets/group_panel.dart'; @@ -352,7 +355,7 @@ class VideoIntroController extends GetxController { builder: (context) { String videoUrl = '${HttpString.baseUrl}/video/$bvid'; return AlertDialog( - title: const Text('分享方式'), + title: const Text('请选择'), actions: [ TextButton( onPressed: () { @@ -361,6 +364,11 @@ class VideoIntroController extends GetxController { Get.back(); }, child: const Text('复制链接')), + TextButton( + onPressed: () { + launchUrl(Uri.parse(videoUrl)); + }, + child: const Text('其它app打开')), TextButton( onPressed: () async { var result = await Share.share('${videoDetail.value.title} ' @@ -541,18 +549,27 @@ class VideoIntroController extends GetxController { final List pages = videoDetail.value.pages!; episodes.addAll(pages); } + final VideoDetailController videoDetailCtr = + Get.find(tag: heroTag); + final PlayRepeat platRepeat = videoDetailCtr.plPlayerController.playRepeat; + + if (episodes.isEmpty) { + if (platRepeat == PlayRepeat.autoPlayRelated) { + return playRelated(); + } + return false; + } final int currentIndex = episodes.indexWhere((e) => e.cid == lastPlayCid.value); int nextIndex = currentIndex + 1; - final VideoDetailController videoDetailCtr = - Get.find(tag: heroTag); - final PlayRepeat platRepeat = videoDetailCtr.plPlayerController.playRepeat; // 列表循环 if (nextIndex >= episodes.length) { if (platRepeat == PlayRepeat.listCycle) { nextIndex = 0; + } else if (platRepeat == PlayRepeat.autoPlayRelated) { + return playRelated(); } else { return false; } @@ -564,6 +581,30 @@ class VideoIntroController extends GetxController { return true; } + bool playRelated() { + final RelatedController relatedCtr = + Get.find(tag: heroTag); + if (relatedCtr.relatedVideoList.isEmpty) { + return false; + } + + final HotVideoItemModel videoItem = relatedCtr.relatedVideoList[0]; + try { + if (videoItem.cid != null) { + Get.offNamed('/video?bvid=${videoItem.bvid}&cid=${videoItem.cid}', + arguments: {'videoItem': videoItem, 'heroTag': heroTag}); + // changeSeasonOrbangu(videoItem.bvid, videoItem.cid, videoItem.aid); + } else { + SearchHttp.ab2c(aid: videoItem.aid, bvid: videoItem.bvid).then((cid) => + Get.offNamed('/video?bvid=${videoItem.bvid}&cid=${videoItem.cid}', + arguments: {'videoItem': videoItem, 'heroTag': heroTag})); + } + } catch (err) { + SmartDialog.showToast(err.toString()); + } + return true; + } + // 设置关注分组 void setFollowGroup() { Get.bottomSheet( diff --git a/lib/pages/video/detail/widgets/header_control.dart b/lib/pages/video/detail/widgets/header_control.dart index 873679d8..d006445a 100644 --- a/lib/pages/video/detail/widgets/header_control.dart +++ b/lib/pages/video/detail/widgets/header_control.dart @@ -1110,7 +1110,7 @@ class _HeaderControlState extends State { builder: (BuildContext context) { return Container( width: double.infinity, - height: 250, + height: 300, clipBehavior: Clip.hardEdge, decoration: BoxDecoration( color: Theme.of(context).colorScheme.background, diff --git a/lib/plugin/pl_player/models/play_repeat.dart b/lib/plugin/pl_player/models/play_repeat.dart index 89ee68e4..c614087d 100644 --- a/lib/plugin/pl_player/models/play_repeat.dart +++ b/lib/plugin/pl_player/models/play_repeat.dart @@ -3,6 +3,7 @@ enum PlayRepeat { listOrder, singleCycle, listCycle, + autoPlayRelated, } extension PlayRepeatExtension on PlayRepeat { @@ -11,6 +12,7 @@ extension PlayRepeatExtension on PlayRepeat { '顺序播放', '单个循环', '列表循环', + '自动连播', ]; String get description => _descList[index]; @@ -19,6 +21,7 @@ extension PlayRepeatExtension on PlayRepeat { 2, 3, 4, + 5, ]; double get value => _valueList[index]; double get defaultValue => _valueList[1];