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/id_utils.dart';
|
||||||
import 'package:PiliPalaX/utils/storage.dart';
|
import 'package:PiliPalaX/utils/storage.dart';
|
||||||
import 'package:share_plus/share_plus.dart';
|
import 'package:share_plus/share_plus.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
class BangumiIntroController extends GetxController {
|
class BangumiIntroController extends GetxController {
|
||||||
// 视频bvid
|
// 视频bvid
|
||||||
@@ -237,7 +238,7 @@ class BangumiIntroController extends GetxController {
|
|||||||
builder: (context) {
|
builder: (context) {
|
||||||
String videoUrl = '${HttpString.baseUrl}/video/$bvid';
|
String videoUrl = '${HttpString.baseUrl}/video/$bvid';
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: const Text('分享方式'),
|
title: const Text('请选择'),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@@ -245,6 +246,11 @@ class BangumiIntroController extends GetxController {
|
|||||||
SmartDialog.showToast('已复制');
|
SmartDialog.showToast('已复制');
|
||||||
},
|
},
|
||||||
child: const Text('复制链接到剪贴板')),
|
child: const Text('复制链接到剪贴板')),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
launchUrl(Uri.parse(videoUrl));
|
||||||
|
},
|
||||||
|
child: const Text('其它app打开')),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
var result =
|
var result =
|
||||||
@@ -340,22 +346,29 @@ class BangumiIntroController extends GetxController {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 列表循环或者顺序播放时,自动播放下一个
|
/// 列表循环或者顺序播放时,自动播放下一个;自动连播时,播放相关视频
|
||||||
bool nextPlay() {
|
bool nextPlay() {
|
||||||
late List episodes;
|
late List episodes;
|
||||||
if (bangumiDetail.value.episodes != null) {
|
|
||||||
episodes = bangumiDetail.value.episodes!;
|
|
||||||
}
|
|
||||||
VideoDetailController videoDetailCtr =
|
VideoDetailController videoDetailCtr =
|
||||||
Get.find<VideoDetailController>(tag: Get.arguments['heroTag']);
|
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 =
|
int currentIndex =
|
||||||
episodes.indexWhere((e) => e.cid == videoDetailCtr.cid.value);
|
episodes.indexWhere((e) => e.cid == videoDetailCtr.cid.value);
|
||||||
int nextIndex = currentIndex + 1;
|
int nextIndex = currentIndex + 1;
|
||||||
PlayRepeat platRepeat = videoDetailCtr.plPlayerController.playRepeat;
|
|
||||||
// 列表循环
|
// 列表循环
|
||||||
if (nextIndex == episodes.length - 1) {
|
if (nextIndex == episodes.length - 1) {
|
||||||
if (platRepeat == PlayRepeat.listCycle) {
|
if (platRepeat == PlayRepeat.listCycle) {
|
||||||
nextIndex = 0;
|
nextIndex = 0;
|
||||||
|
} else if (platRepeat == PlayRepeat.autoPlayRelated) {
|
||||||
|
return playRelated();
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -366,4 +379,9 @@ class BangumiIntroController extends GetxController {
|
|||||||
changeSeasonOrbangu(bvid, cid, aid);
|
changeSeasonOrbangu(bvid, cid, aid);
|
||||||
return true;
|
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:PiliPalaX/utils/storage.dart';
|
||||||
import 'package:share_plus/share_plus.dart';
|
import 'package:share_plus/share_plus.dart';
|
||||||
import 'package:PiliPalaX/pages/member/controller.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 '../related/index.dart';
|
||||||
import 'widgets/group_panel.dart';
|
import 'widgets/group_panel.dart';
|
||||||
|
|
||||||
@@ -352,7 +355,7 @@ class VideoIntroController extends GetxController {
|
|||||||
builder: (context) {
|
builder: (context) {
|
||||||
String videoUrl = '${HttpString.baseUrl}/video/$bvid';
|
String videoUrl = '${HttpString.baseUrl}/video/$bvid';
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: const Text('分享方式'),
|
title: const Text('请选择'),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@@ -361,6 +364,11 @@ class VideoIntroController extends GetxController {
|
|||||||
Get.back();
|
Get.back();
|
||||||
},
|
},
|
||||||
child: const Text('复制链接')),
|
child: const Text('复制链接')),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
launchUrl(Uri.parse(videoUrl));
|
||||||
|
},
|
||||||
|
child: const Text('其它app打开')),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
var result = await Share.share('${videoDetail.value.title} '
|
var result = await Share.share('${videoDetail.value.title} '
|
||||||
@@ -541,18 +549,27 @@ class VideoIntroController extends GetxController {
|
|||||||
final List<Part> pages = videoDetail.value.pages!;
|
final List<Part> pages = videoDetail.value.pages!;
|
||||||
episodes.addAll(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 =
|
final int currentIndex =
|
||||||
episodes.indexWhere((e) => e.cid == lastPlayCid.value);
|
episodes.indexWhere((e) => e.cid == lastPlayCid.value);
|
||||||
int nextIndex = currentIndex + 1;
|
int nextIndex = currentIndex + 1;
|
||||||
final VideoDetailController videoDetailCtr =
|
|
||||||
Get.find<VideoDetailController>(tag: heroTag);
|
|
||||||
final PlayRepeat platRepeat = videoDetailCtr.plPlayerController.playRepeat;
|
|
||||||
|
|
||||||
// 列表循环
|
// 列表循环
|
||||||
if (nextIndex >= episodes.length) {
|
if (nextIndex >= episodes.length) {
|
||||||
if (platRepeat == PlayRepeat.listCycle) {
|
if (platRepeat == PlayRepeat.listCycle) {
|
||||||
nextIndex = 0;
|
nextIndex = 0;
|
||||||
|
} else if (platRepeat == PlayRepeat.autoPlayRelated) {
|
||||||
|
return playRelated();
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -564,6 +581,30 @@ class VideoIntroController extends GetxController {
|
|||||||
return true;
|
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() {
|
void setFollowGroup() {
|
||||||
Get.bottomSheet(
|
Get.bottomSheet(
|
||||||
|
|||||||
@@ -1110,7 +1110,7 @@ class _HeaderControlState extends State<HeaderControl> {
|
|||||||
builder: (BuildContext context) {
|
builder: (BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
height: 250,
|
height: 300,
|
||||||
clipBehavior: Clip.hardEdge,
|
clipBehavior: Clip.hardEdge,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Theme.of(context).colorScheme.background,
|
color: Theme.of(context).colorScheme.background,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ enum PlayRepeat {
|
|||||||
listOrder,
|
listOrder,
|
||||||
singleCycle,
|
singleCycle,
|
||||||
listCycle,
|
listCycle,
|
||||||
|
autoPlayRelated,
|
||||||
}
|
}
|
||||||
|
|
||||||
extension PlayRepeatExtension on PlayRepeat {
|
extension PlayRepeatExtension on PlayRepeat {
|
||||||
@@ -11,6 +12,7 @@ extension PlayRepeatExtension on PlayRepeat {
|
|||||||
'顺序播放',
|
'顺序播放',
|
||||||
'单个循环',
|
'单个循环',
|
||||||
'列表循环',
|
'列表循环',
|
||||||
|
'自动连播',
|
||||||
];
|
];
|
||||||
String get description => _descList[index];
|
String get description => _descList[index];
|
||||||
|
|
||||||
@@ -19,6 +21,7 @@ extension PlayRepeatExtension on PlayRepeat {
|
|||||||
2,
|
2,
|
||||||
3,
|
3,
|
||||||
4,
|
4,
|
||||||
|
5,
|
||||||
];
|
];
|
||||||
double get value => _valueList[index];
|
double get value => _valueList[index];
|
||||||
double get defaultValue => _valueList[1];
|
double get defaultValue => _valueList[1];
|
||||||
|
|||||||
Reference in New Issue
Block a user