mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: custom show related video
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -216,6 +216,8 @@ class VideoDetailController extends GetxController
|
||||
late String cacheSecondDecode;
|
||||
late int cacheAudioQa;
|
||||
|
||||
late final showRelatedVideo = GStorage.showRelatedVideo;
|
||||
|
||||
late final bool enableSponsorBlock;
|
||||
PlayerStatus? playerStatus;
|
||||
StreamSubscription<Duration>? positionSubscription;
|
||||
@@ -236,6 +238,8 @@ class VideoDetailController extends GetxController
|
||||
RxString sourceType = 'normal'.obs;
|
||||
List<MediaVideoItemModel> mediaList = <MediaVideoItemModel>[];
|
||||
RxString watchLaterTitle = ''.obs;
|
||||
bool get isPlayAll =>
|
||||
sourceType.value == 'watchLater' || sourceType.value == 'fav';
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
@@ -366,9 +370,11 @@ class VideoDetailController extends GetxController
|
||||
..bvid = bvid
|
||||
..queryVideoIntro();
|
||||
|
||||
Get.find<RelatedController>(tag: heroTag)
|
||||
..bvid = bvid
|
||||
..onRefresh();
|
||||
if (showRelatedVideo) {
|
||||
Get.find<RelatedController>(tag: heroTag)
|
||||
..bvid = bvid
|
||||
..onRefresh();
|
||||
}
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
|
||||
@@ -550,12 +550,13 @@ class VideoIntroController extends GetxController
|
||||
videoDetailCtr.danmakuCid.value = cid;
|
||||
videoDetailCtr.queryVideoUrl();
|
||||
// 重新请求相关视频
|
||||
try {
|
||||
final RelatedController relatedCtr =
|
||||
Get.find<RelatedController>(tag: heroTag);
|
||||
relatedCtr.bvid = bvid;
|
||||
relatedCtr.queryData();
|
||||
} catch (_) {}
|
||||
if (videoDetailCtr.showRelatedVideo) {
|
||||
try {
|
||||
Get.find<RelatedController>(tag: heroTag)
|
||||
..bvid = bvid
|
||||
..queryData();
|
||||
} catch (_) {}
|
||||
}
|
||||
// 重新请求评论
|
||||
try {
|
||||
final VideoReplyController videoReplyCtr =
|
||||
@@ -652,8 +653,7 @@ class VideoIntroController extends GetxController
|
||||
final VideoDetailController videoDetailCtr =
|
||||
Get.find<VideoDetailController>(tag: heroTag);
|
||||
|
||||
if (videoDetailController.sourceType.value == 'watchLater' ||
|
||||
videoDetailController.sourceType.value == 'fav') {
|
||||
if (videoDetailController.isPlayAll) {
|
||||
episodes.addAll(videoDetailCtr.mediaList);
|
||||
} else if ((videoDetail.value.pages?.length ?? 0) > 1) {
|
||||
isPages = true;
|
||||
@@ -671,7 +671,8 @@ class VideoIntroController extends GetxController
|
||||
final PlayRepeat platRepeat = videoDetailCtr.plPlayerController.playRepeat;
|
||||
|
||||
if (episodes.isEmpty) {
|
||||
if (platRepeat == PlayRepeat.autoPlayRelated) {
|
||||
if (platRepeat == PlayRepeat.autoPlayRelated &&
|
||||
videoDetailCtr.showRelatedVideo) {
|
||||
return playRelated();
|
||||
}
|
||||
return false;
|
||||
@@ -692,7 +693,8 @@ class VideoIntroController extends GetxController
|
||||
if (nextIndex >= episodes.length) {
|
||||
if (platRepeat == PlayRepeat.listCycle) {
|
||||
nextIndex = 0;
|
||||
} else if (platRepeat == PlayRepeat.autoPlayRelated) {
|
||||
} else if (platRepeat == PlayRepeat.autoPlayRelated &&
|
||||
videoDetailCtr.showRelatedVideo) {
|
||||
return playRelated();
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -795,7 +795,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
SearchType.media_bangumi,
|
||||
'相关视频',
|
||||
videoDetailController.videoType ==
|
||||
SearchType.media_bangumi,
|
||||
SearchType.media_bangumi ||
|
||||
videoDetailController.showRelatedVideo.not,
|
||||
),
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
@@ -803,7 +804,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
controller: videoDetailController.tabCtr,
|
||||
children: <Widget>[
|
||||
if (videoDetailController.videoType ==
|
||||
SearchType.video)
|
||||
SearchType.video &&
|
||||
videoDetailController.showRelatedVideo)
|
||||
CustomScrollView(
|
||||
controller: _introController,
|
||||
slivers: [
|
||||
@@ -1296,7 +1298,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
showIntroDetail: showIntroDetail,
|
||||
showEpisodes: showEpisodes,
|
||||
),
|
||||
if (needRelated) ...[
|
||||
if (needRelated && videoDetailController.showRelatedVideo) ...[
|
||||
SliverToBoxAdapter(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
@@ -1323,12 +1325,18 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
),
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
child: SizedBox(height: MediaQuery.paddingOf(context).bottom),
|
||||
child: SizedBox(
|
||||
height: MediaQuery.paddingOf(context).bottom +
|
||||
(videoDetailController.isPlayAll &&
|
||||
MediaQuery.orientationOf(context) ==
|
||||
Orientation.landscape
|
||||
? 75
|
||||
: 0),
|
||||
),
|
||||
)
|
||||
],
|
||||
);
|
||||
if (videoDetailController.sourceType.value == 'watchLater' ||
|
||||
videoDetailController.sourceType.value == 'fav') {
|
||||
if (videoDetailController.isPlayAll) {
|
||||
return Stack(
|
||||
children: [
|
||||
introPanel(),
|
||||
|
||||
Reference in New Issue
Block a user