mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: try-catch nextplay
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -576,38 +576,42 @@ class BangumiIntroController extends CommonController {
|
|||||||
|
|
||||||
/// 列表循环或者顺序播放时,自动播放下一个;自动连播时,播放相关视频
|
/// 列表循环或者顺序播放时,自动播放下一个;自动连播时,播放相关视频
|
||||||
bool nextPlay() {
|
bool nextPlay() {
|
||||||
late List episodes;
|
try {
|
||||||
VideoDetailController videoDetailCtr =
|
late List episodes;
|
||||||
Get.find<VideoDetailController>(tag: Get.arguments['heroTag']);
|
VideoDetailController videoDetailCtr =
|
||||||
PlayRepeat playRepeat = videoDetailCtr.plPlayerController.playRepeat;
|
Get.find<VideoDetailController>(tag: Get.arguments['heroTag']);
|
||||||
|
PlayRepeat playRepeat = videoDetailCtr.plPlayerController.playRepeat;
|
||||||
|
|
||||||
if ((loadingState.value as Success).response.episodes != null) {
|
if ((loadingState.value as Success).response.episodes != null) {
|
||||||
episodes = (loadingState.value as Success).response.episodes!;
|
episodes = (loadingState.value as Success).response.episodes!;
|
||||||
} else {
|
|
||||||
if (playRepeat == PlayRepeat.autoPlayRelated) {
|
|
||||||
return playRelated();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int currentIndex =
|
|
||||||
episodes.indexWhere((e) => e.cid == videoDetailCtr.cid.value);
|
|
||||||
int nextIndex = currentIndex + 1;
|
|
||||||
// 列表循环
|
|
||||||
if (nextIndex >= episodes.length) {
|
|
||||||
if (playRepeat == PlayRepeat.listCycle) {
|
|
||||||
nextIndex = 0;
|
|
||||||
} else if (playRepeat == PlayRepeat.autoPlayRelated) {
|
|
||||||
return playRelated();
|
|
||||||
} else {
|
} else {
|
||||||
return false;
|
if (playRepeat == PlayRepeat.autoPlayRelated) {
|
||||||
|
return playRelated();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
int currentIndex =
|
||||||
|
episodes.indexWhere((e) => e.cid == videoDetailCtr.cid.value);
|
||||||
|
int nextIndex = currentIndex + 1;
|
||||||
|
// 列表循环
|
||||||
|
if (nextIndex >= episodes.length) {
|
||||||
|
if (playRepeat == PlayRepeat.listCycle) {
|
||||||
|
nextIndex = 0;
|
||||||
|
} else if (playRepeat == PlayRepeat.autoPlayRelated) {
|
||||||
|
return playRelated();
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int epid = episodes[nextIndex].epId;
|
||||||
|
int cid = episodes[nextIndex].cid;
|
||||||
|
String bvid = episodes[nextIndex].bvid;
|
||||||
|
int aid = episodes[nextIndex].aid;
|
||||||
|
dynamic cover = episodes[nextIndex].cover;
|
||||||
|
changeSeasonOrbangu(epid, bvid, cid, aid, cover);
|
||||||
|
return true;
|
||||||
|
} catch (_) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
int epid = episodes[nextIndex].epId;
|
|
||||||
int cid = episodes[nextIndex].cid;
|
|
||||||
String bvid = episodes[nextIndex].bvid;
|
|
||||||
int aid = episodes[nextIndex].aid;
|
|
||||||
dynamic cover = episodes[nextIndex].cover;
|
|
||||||
changeSeasonOrbangu(epid, bvid, cid, aid, cover);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool playRelated() {
|
bool playRelated() {
|
||||||
|
|||||||
@@ -728,71 +728,76 @@ class VideoIntroController extends GetxController
|
|||||||
|
|
||||||
/// 列表循环或者顺序播放时,自动播放下一个
|
/// 列表循环或者顺序播放时,自动播放下一个
|
||||||
bool nextPlay() {
|
bool nextPlay() {
|
||||||
final List episodes = [];
|
try {
|
||||||
bool isPages = false;
|
final List episodes = [];
|
||||||
final videoDetailCtr = Get.find<VideoDetailController>(tag: heroTag);
|
bool isPages = false;
|
||||||
|
final videoDetailCtr = Get.find<VideoDetailController>(tag: heroTag);
|
||||||
|
|
||||||
// part -> playall -> season
|
// part -> playall -> season
|
||||||
if ((videoDetail.value.pages?.length ?? 0) > 1) {
|
if ((videoDetail.value.pages?.length ?? 0) > 1) {
|
||||||
isPages = true;
|
isPages = true;
|
||||||
final List<Part> pages = videoDetail.value.pages!;
|
final List<Part> pages = videoDetail.value.pages!;
|
||||||
episodes.addAll(pages);
|
episodes.addAll(pages);
|
||||||
} else if (videoDetailCtr.isPlayAll) {
|
} else if (videoDetailCtr.isPlayAll) {
|
||||||
episodes.addAll(videoDetailCtr.mediaList);
|
episodes.addAll(videoDetailCtr.mediaList);
|
||||||
} else if (videoDetail.value.ugcSeason != null) {
|
} else if (videoDetail.value.ugcSeason != null) {
|
||||||
final UgcSeason ugcSeason = videoDetail.value.ugcSeason!;
|
final UgcSeason ugcSeason = videoDetail.value.ugcSeason!;
|
||||||
final List<SectionItem> sections = ugcSeason.sections!;
|
final List<SectionItem> sections = ugcSeason.sections!;
|
||||||
for (int i = 0; i < sections.length; i++) {
|
for (int i = 0; i < sections.length; i++) {
|
||||||
final List<EpisodeItem> episodesList = sections[i].episodes!;
|
final List<EpisodeItem> episodesList = sections[i].episodes!;
|
||||||
episodes.addAll(episodesList);
|
episodes.addAll(episodesList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
final PlayRepeat playRepeat = videoDetailCtr.plPlayerController.playRepeat;
|
final PlayRepeat playRepeat =
|
||||||
|
videoDetailCtr.plPlayerController.playRepeat;
|
||||||
|
|
||||||
if (episodes.isEmpty) {
|
if (episodes.isEmpty) {
|
||||||
if (playRepeat == PlayRepeat.autoPlayRelated &&
|
if (playRepeat == PlayRepeat.autoPlayRelated &&
|
||||||
videoDetailCtr.showRelatedVideo) {
|
videoDetailCtr.showRelatedVideo) {
|
||||||
return playRelated();
|
return playRelated();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final int currentIndex =
|
||||||
|
episodes.indexWhere((e) => e.cid == videoDetailCtr.cid.value);
|
||||||
|
int nextIndex = currentIndex + 1;
|
||||||
|
|
||||||
|
if (videoDetailCtr.isPlayAll && currentIndex == episodes.length - 2) {
|
||||||
|
videoDetailCtr.getMediaList();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 列表循环
|
||||||
|
if (nextIndex >= episodes.length) {
|
||||||
|
if (playRepeat == PlayRepeat.listCycle) {
|
||||||
|
nextIndex = 0;
|
||||||
|
} else if (playRepeat == PlayRepeat.autoPlayRelated &&
|
||||||
|
videoDetailCtr.showRelatedVideo) {
|
||||||
|
return playRelated();
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int cid = episodes[nextIndex].cid!;
|
||||||
|
|
||||||
|
while (cid == -1) {
|
||||||
|
SmartDialog.showToast('当前视频暂不支持播放,自动跳过');
|
||||||
|
nextIndex++;
|
||||||
|
if (nextIndex >= episodes.length) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
cid = episodes[nextIndex].cid!;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String rBvid = isPages ? bvid : episodes[nextIndex].bvid;
|
||||||
|
final int rAid = isPages ? IdUtils.bv2av(bvid) : episodes[nextIndex].aid!;
|
||||||
|
changeSeasonOrbangu(null, rBvid, cid, rAid, null);
|
||||||
|
return true;
|
||||||
|
} catch (_) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int currentIndex =
|
|
||||||
episodes.indexWhere((e) => e.cid == videoDetailCtr.cid.value);
|
|
||||||
int nextIndex = currentIndex + 1;
|
|
||||||
|
|
||||||
if (videoDetailCtr.isPlayAll && currentIndex == episodes.length - 2) {
|
|
||||||
videoDetailCtr.getMediaList();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 列表循环
|
|
||||||
if (nextIndex >= episodes.length) {
|
|
||||||
if (playRepeat == PlayRepeat.listCycle) {
|
|
||||||
nextIndex = 0;
|
|
||||||
} else if (playRepeat == PlayRepeat.autoPlayRelated &&
|
|
||||||
videoDetailCtr.showRelatedVideo) {
|
|
||||||
return playRelated();
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int cid = episodes[nextIndex].cid!;
|
|
||||||
|
|
||||||
while (cid == -1) {
|
|
||||||
SmartDialog.showToast('当前视频暂不支持播放,自动跳过');
|
|
||||||
nextIndex++;
|
|
||||||
if (nextIndex >= episodes.length) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
cid = episodes[nextIndex].cid!;
|
|
||||||
}
|
|
||||||
|
|
||||||
final String rBvid = isPages ? bvid : episodes[nextIndex].bvid;
|
|
||||||
final int rAid = isPages ? IdUtils.bv2av(bvid) : episodes[nextIndex].aid!;
|
|
||||||
changeSeasonOrbangu(null, rBvid, cid, rAid, null);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool playRelated() {
|
bool playRelated() {
|
||||||
|
|||||||
Reference in New Issue
Block a user