mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: 初步自动连播功能;分享新增其它app打开
This commit is contained in:
@@ -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<VideoDetailController>(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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Part> pages = videoDetail.value.pages!;
|
||||
episodes.addAll(pages);
|
||||
}
|
||||
final VideoDetailController videoDetailCtr =
|
||||
Get.find<VideoDetailController>(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<VideoDetailController>(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<RelatedController>(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(
|
||||
|
||||
@@ -1110,7 +1110,7 @@ class _HeaderControlState extends State<HeaderControl> {
|
||||
builder: (BuildContext context) {
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
height: 250,
|
||||
height: 300,
|
||||
clipBehavior: Clip.hardEdge,
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).colorScheme.background,
|
||||
|
||||
Reference in New Issue
Block a user