feat: custom show related video

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2024-12-23 17:12:43 +08:00
parent c8e89653ed
commit 812170ce38
6 changed files with 49 additions and 19 deletions

View File

@@ -64,6 +64,7 @@ class _MediaPageState extends State<MediaPage>
toolbarHeight: 30, toolbarHeight: 30,
), ),
body: SingleChildScrollView( body: SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
controller: mediaController.scrollController, controller: mediaController.scrollController,
child: Column( child: Column(
children: [ children: [
@@ -183,6 +184,9 @@ class _MediaPageState extends State<MediaPage>
height: MediaQuery.textScalerOf(context).scale(200), height: MediaQuery.textScalerOf(context).scale(200),
child: Obx(() => _buildBody(mediaController.loadingState.value)), child: Obx(() => _buildBody(mediaController.loadingState.value)),
), ),
SizedBox(
height: MediaQuery.paddingOf(context).bottom + 100,
)
], ],
); );
} }

View File

@@ -223,6 +223,12 @@ class _ExtraSettingState extends State<ExtraSetting> {
setKey: SettingBoxKey.showViewPoints, setKey: SettingBoxKey.showViewPoints,
defaultVal: true, defaultVal: true,
), ),
SetSwitchItem(
title: '视频页显示相关视频',
leading: Icon(Icons.recommend_outlined),
setKey: SettingBoxKey.showRelatedVideo,
defaultVal: true,
),
Obx( Obx(
() => ListTile( () => ListTile(
enableFeedback: true, enableFeedback: true,

View File

@@ -216,6 +216,8 @@ class VideoDetailController extends GetxController
late String cacheSecondDecode; late String cacheSecondDecode;
late int cacheAudioQa; late int cacheAudioQa;
late final showRelatedVideo = GStorage.showRelatedVideo;
late final bool enableSponsorBlock; late final bool enableSponsorBlock;
PlayerStatus? playerStatus; PlayerStatus? playerStatus;
StreamSubscription<Duration>? positionSubscription; StreamSubscription<Duration>? positionSubscription;
@@ -236,6 +238,8 @@ class VideoDetailController extends GetxController
RxString sourceType = 'normal'.obs; RxString sourceType = 'normal'.obs;
List<MediaVideoItemModel> mediaList = <MediaVideoItemModel>[]; List<MediaVideoItemModel> mediaList = <MediaVideoItemModel>[];
RxString watchLaterTitle = ''.obs; RxString watchLaterTitle = ''.obs;
bool get isPlayAll =>
sourceType.value == 'watchLater' || sourceType.value == 'fav';
@override @override
void onInit() { void onInit() {
@@ -366,9 +370,11 @@ class VideoDetailController extends GetxController
..bvid = bvid ..bvid = bvid
..queryVideoIntro(); ..queryVideoIntro();
Get.find<RelatedController>(tag: heroTag) if (showRelatedVideo) {
..bvid = bvid Get.find<RelatedController>(tag: heroTag)
..onRefresh(); ..bvid = bvid
..onRefresh();
}
} catch (_) {} } catch (_) {}
} }

View File

@@ -550,12 +550,13 @@ class VideoIntroController extends GetxController
videoDetailCtr.danmakuCid.value = cid; videoDetailCtr.danmakuCid.value = cid;
videoDetailCtr.queryVideoUrl(); videoDetailCtr.queryVideoUrl();
// 重新请求相关视频 // 重新请求相关视频
try { if (videoDetailCtr.showRelatedVideo) {
final RelatedController relatedCtr = try {
Get.find<RelatedController>(tag: heroTag); Get.find<RelatedController>(tag: heroTag)
relatedCtr.bvid = bvid; ..bvid = bvid
relatedCtr.queryData(); ..queryData();
} catch (_) {} } catch (_) {}
}
// 重新请求评论 // 重新请求评论
try { try {
final VideoReplyController videoReplyCtr = final VideoReplyController videoReplyCtr =
@@ -652,8 +653,7 @@ class VideoIntroController extends GetxController
final VideoDetailController videoDetailCtr = final VideoDetailController videoDetailCtr =
Get.find<VideoDetailController>(tag: heroTag); Get.find<VideoDetailController>(tag: heroTag);
if (videoDetailController.sourceType.value == 'watchLater' || if (videoDetailController.isPlayAll) {
videoDetailController.sourceType.value == 'fav') {
episodes.addAll(videoDetailCtr.mediaList); episodes.addAll(videoDetailCtr.mediaList);
} else if ((videoDetail.value.pages?.length ?? 0) > 1) { } else if ((videoDetail.value.pages?.length ?? 0) > 1) {
isPages = true; isPages = true;
@@ -671,7 +671,8 @@ class VideoIntroController extends GetxController
final PlayRepeat platRepeat = videoDetailCtr.plPlayerController.playRepeat; final PlayRepeat platRepeat = videoDetailCtr.plPlayerController.playRepeat;
if (episodes.isEmpty) { if (episodes.isEmpty) {
if (platRepeat == PlayRepeat.autoPlayRelated) { if (platRepeat == PlayRepeat.autoPlayRelated &&
videoDetailCtr.showRelatedVideo) {
return playRelated(); return playRelated();
} }
return false; return false;
@@ -692,7 +693,8 @@ class VideoIntroController extends GetxController
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) { } else if (platRepeat == PlayRepeat.autoPlayRelated &&
videoDetailCtr.showRelatedVideo) {
return playRelated(); return playRelated();
} else { } else {
return false; return false;

View File

@@ -795,7 +795,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
SearchType.media_bangumi, SearchType.media_bangumi,
'相关视频', '相关视频',
videoDetailController.videoType == videoDetailController.videoType ==
SearchType.media_bangumi, SearchType.media_bangumi ||
videoDetailController.showRelatedVideo.not,
), ),
Expanded( Expanded(
child: TabBarView( child: TabBarView(
@@ -803,7 +804,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
controller: videoDetailController.tabCtr, controller: videoDetailController.tabCtr,
children: <Widget>[ children: <Widget>[
if (videoDetailController.videoType == if (videoDetailController.videoType ==
SearchType.video) SearchType.video &&
videoDetailController.showRelatedVideo)
CustomScrollView( CustomScrollView(
controller: _introController, controller: _introController,
slivers: [ slivers: [
@@ -1296,7 +1298,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
showIntroDetail: showIntroDetail, showIntroDetail: showIntroDetail,
showEpisodes: showEpisodes, showEpisodes: showEpisodes,
), ),
if (needRelated) ...[ if (needRelated && videoDetailController.showRelatedVideo) ...[
SliverToBoxAdapter( SliverToBoxAdapter(
child: Padding( child: Padding(
padding: const EdgeInsets.only( padding: const EdgeInsets.only(
@@ -1323,12 +1325,18 @@ class _VideoDetailPageState extends State<VideoDetailPage>
), ),
), ),
SliverToBoxAdapter( 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' || if (videoDetailController.isPlayAll) {
videoDetailController.sourceType.value == 'fav') {
return Stack( return Stack(
children: [ children: [
introPanel(), introPanel(),

View File

@@ -113,6 +113,9 @@ class GStorage {
static bool get showViewPoints => static bool get showViewPoints =>
setting.get(SettingBoxKey.showViewPoints, defaultValue: true); setting.get(SettingBoxKey.showViewPoints, defaultValue: true);
static bool get showRelatedVideo =>
setting.get(SettingBoxKey.showRelatedVideo, defaultValue: true);
static List<double> get dynamicDetailRatio => static List<double> get dynamicDetailRatio =>
setting.get(SettingBoxKey.dynamicDetailRatio, defaultValue: [60.0, 40.0]); setting.get(SettingBoxKey.dynamicDetailRatio, defaultValue: [60.0, 40.0]);
@@ -306,6 +309,7 @@ class SettingBoxKey {
schemeVariant = 'schemeVariant', schemeVariant = 'schemeVariant',
grpcReply = 'grpcReply', grpcReply = 'grpcReply',
showViewPoints = 'showViewPoints', showViewPoints = 'showViewPoints',
showRelatedVideo = 'showRelatedVideo',
// Sponsor Block // Sponsor Block
enableSponsorBlock = 'enableSponsorBlock', enableSponsorBlock = 'enableSponsorBlock',