mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-21 17:46:24 +08:00
opt change episode
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -5,11 +5,14 @@ import 'package:PiliPlus/grpc/bilibili/app/viewunite/pgcanymodel.pb.dart'
|
||||
show ViewPgcAny;
|
||||
import 'package:PiliPlus/grpc/view.dart';
|
||||
import 'package:PiliPlus/http/constants.dart';
|
||||
import 'package:PiliPlus/http/search.dart';
|
||||
import 'package:PiliPlus/http/video.dart';
|
||||
import 'package:PiliPlus/models/pgc_lcf.dart';
|
||||
import 'package:PiliPlus/models_new/pgc/pgc_info_model/episode.dart';
|
||||
import 'package:PiliPlus/models_new/pgc/pgc_info_model/result.dart';
|
||||
import 'package:PiliPlus/models_new/triple/pgc_triple.dart';
|
||||
import 'package:PiliPlus/models_new/video/video_detail/episode.dart'
|
||||
hide EpisodeItem;
|
||||
import 'package:PiliPlus/models_new/video/video_detail/stat_detail.dart';
|
||||
import 'package:PiliPlus/pages/common/common_intro_controller.dart';
|
||||
import 'package:PiliPlus/pages/dynamics_repost/view.dart';
|
||||
@@ -20,6 +23,7 @@ import 'package:PiliPlus/plugin/pl_player/models/play_repeat.dart';
|
||||
import 'package:PiliPlus/services/service_locator.dart';
|
||||
import 'package:PiliPlus/utils/feed_back.dart';
|
||||
import 'package:PiliPlus/utils/global_data.dart';
|
||||
import 'package:PiliPlus/utils/id_utils.dart';
|
||||
import 'package:PiliPlus/utils/page_utils.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -257,41 +261,55 @@ class PgcIntroController extends CommonIntroController {
|
||||
}
|
||||
|
||||
// 修改分P或番剧分集
|
||||
void onChangeEpisode(dynamic epId, bvid, cid, aid, cover) {
|
||||
// 重新获取视频资源
|
||||
this.epId = epId;
|
||||
this.bvid = bvid;
|
||||
Future<void> onChangeEpisode(BaseEpisodeItem episode) async {
|
||||
try {
|
||||
final int epId = episode.epId!;
|
||||
final String bvid = episode.bvid ?? this.bvid;
|
||||
final int aid = episode.aid ?? IdUtils.bv2av(bvid);
|
||||
final int? cid =
|
||||
episode.cid ?? await SearchHttp.ab2c(aid: aid, bvid: bvid);
|
||||
if (cid == null) {
|
||||
return;
|
||||
}
|
||||
final String? cover = episode.cover;
|
||||
|
||||
final videoDetailCtr =
|
||||
Get.find<VideoDetailController>(tag: Get.arguments['heroTag'])
|
||||
..plPlayerController.pause()
|
||||
..makeHeartBeat()
|
||||
..onReset()
|
||||
..epId = epId
|
||||
..bvid = bvid
|
||||
..cid.value = cid
|
||||
..queryVideoUrl();
|
||||
if (cover is String && cover.isNotEmpty) {
|
||||
videoDetailCtr.cover.value = cover;
|
||||
// 重新获取视频资源
|
||||
this.epId = epId;
|
||||
this.bvid = bvid;
|
||||
|
||||
final videoDetailCtr =
|
||||
Get.find<VideoDetailController>(tag: Get.arguments['heroTag'])
|
||||
..plPlayerController.pause()
|
||||
..makeHeartBeat()
|
||||
..onReset()
|
||||
..epId = epId
|
||||
..bvid = bvid
|
||||
..cid.value = cid
|
||||
..queryVideoUrl();
|
||||
if (cover != null && cover.isNotEmpty) {
|
||||
videoDetailCtr.cover.value = cover;
|
||||
}
|
||||
|
||||
// 重新请求评论
|
||||
if (videoDetailCtr.showReply) {
|
||||
try {
|
||||
Get.find<VideoReplyController>(tag: Get.arguments['heroTag'])
|
||||
..aid = aid
|
||||
..onReload();
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
if (accountService.isLogin.value) {
|
||||
queryPgcLikeCoinFav();
|
||||
}
|
||||
|
||||
hasLater.value = false;
|
||||
this.cid.value = cid;
|
||||
queryVideoIntro();
|
||||
queryOnlineTotal();
|
||||
} catch (e) {
|
||||
debugPrint('pgc onChangeEpisode: $e');
|
||||
}
|
||||
|
||||
// 重新请求评论
|
||||
if (videoDetailCtr.showReply) {
|
||||
try {
|
||||
Get.find<VideoReplyController>(tag: Get.arguments['heroTag'])
|
||||
..aid = aid
|
||||
..onReload();
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
if (accountService.isLogin.value) {
|
||||
queryPgcLikeCoinFav();
|
||||
}
|
||||
|
||||
hasLater.value = false;
|
||||
this.cid.value = cid;
|
||||
queryVideoIntro();
|
||||
queryOnlineTotal();
|
||||
}
|
||||
|
||||
// 追番
|
||||
@@ -342,14 +360,7 @@ class PgcIntroController extends CommonIntroController {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
final episode = episodes[prevIndex];
|
||||
onChangeEpisode(
|
||||
episode.epId,
|
||||
episode.bvid,
|
||||
episode.cid,
|
||||
episode.aid,
|
||||
episode.cover,
|
||||
);
|
||||
onChangeEpisode(episodes[prevIndex]);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -377,14 +388,7 @@ class PgcIntroController extends CommonIntroController {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
final episode = episodes[nextIndex];
|
||||
onChangeEpisode(
|
||||
episode.epId,
|
||||
episode.bvid,
|
||||
episode.cid,
|
||||
episode.aid,
|
||||
episode.cover,
|
||||
);
|
||||
onChangeEpisode(episodes[nextIndex]);
|
||||
return true;
|
||||
} catch (_) {
|
||||
return false;
|
||||
|
||||
@@ -3,6 +3,8 @@ import 'dart:async';
|
||||
import 'package:PiliPlus/models/user/info.dart';
|
||||
import 'package:PiliPlus/models_new/pgc/pgc_info_model/episode.dart';
|
||||
import 'package:PiliPlus/models_new/pgc/pgc_info_model/new_ep.dart';
|
||||
import 'package:PiliPlus/models_new/video/video_detail/episode.dart'
|
||||
hide EpisodeItem;
|
||||
import 'package:PiliPlus/pages/video/controller.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
@@ -23,7 +25,7 @@ class PgcPanel extends StatefulWidget {
|
||||
|
||||
final List<EpisodeItem> pages;
|
||||
final int? cid;
|
||||
final Function onChangeEpisode;
|
||||
final ValueChanged<BaseEpisodeItem> onChangeEpisode;
|
||||
final Function showEpisodes;
|
||||
final String heroTag;
|
||||
final NewEp? newEp;
|
||||
@@ -149,18 +151,10 @@ class _PgcPanelState extends State<PgcPanel> {
|
||||
child: InkWell(
|
||||
borderRadius: const BorderRadius.all(Radius.circular(6)),
|
||||
onTap: () {
|
||||
if (item.badge != null &&
|
||||
item.badge == '会员' &&
|
||||
vipStatus != 1) {
|
||||
if (item.badge == '会员' && vipStatus != 1) {
|
||||
SmartDialog.showToast('需要大会员');
|
||||
}
|
||||
widget.onChangeEpisode(
|
||||
item.epId,
|
||||
item.bvid,
|
||||
item.cid,
|
||||
item.aid,
|
||||
item.cover,
|
||||
);
|
||||
widget.onChangeEpisode(item);
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
|
||||
@@ -465,68 +465,80 @@ class UgcIntroController extends CommonIntroController with ReloadMixin {
|
||||
}
|
||||
|
||||
// 修改分P或番剧分集
|
||||
bool onChangeEpisode(dynamic epid, bvid, cid, aid, cover, [isStein]) {
|
||||
// 重新获取视频资源
|
||||
final videoDetailCtr = Get.find<VideoDetailController>(tag: heroTag);
|
||||
|
||||
if (videoDetailCtr.isPlayAll) {
|
||||
if (videoDetailCtr.mediaList.indexWhere((item) => item.bvid == bvid) ==
|
||||
-1) {
|
||||
PageUtils.toVideoPage(
|
||||
'bvid=$bvid&cid=$cid',
|
||||
arguments: {
|
||||
'pic': cover,
|
||||
'heroTag': Utils.makeHeroTag(bvid),
|
||||
},
|
||||
);
|
||||
return false;
|
||||
Future<void> onChangeEpisode(BaseEpisodeItem episode, {bool? isStein}) async {
|
||||
try {
|
||||
final String bvid = episode.bvid ?? this.bvid;
|
||||
final int aid = episode.aid ?? IdUtils.bv2av(bvid);
|
||||
final int? cid =
|
||||
episode.cid ?? await SearchHttp.ab2c(aid: aid, bvid: bvid);
|
||||
if (cid == null) {
|
||||
return;
|
||||
}
|
||||
final String? cover = episode.cover;
|
||||
|
||||
// 重新获取视频资源
|
||||
final videoDetailCtr = Get.find<VideoDetailController>(tag: heroTag);
|
||||
|
||||
if (videoDetailCtr.isPlayAll) {
|
||||
if (videoDetailCtr.mediaList.indexWhere((item) => item.bvid == bvid) ==
|
||||
-1) {
|
||||
PageUtils.toVideoPage(
|
||||
'bvid=$bvid&cid=$cid',
|
||||
arguments: {
|
||||
'pic': ?cover,
|
||||
'heroTag': Utils.makeHeroTag(bvid),
|
||||
},
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
videoDetailCtr
|
||||
..plPlayerController.pause()
|
||||
..makeHeartBeat()
|
||||
..updateMediaListHistory(aid)
|
||||
..onReset(isStein)
|
||||
..bvid = bvid
|
||||
..oid.value = aid
|
||||
..cid.value = cid
|
||||
..queryVideoUrl();
|
||||
|
||||
if (this.bvid != bvid) {
|
||||
reload = true;
|
||||
aiConclusionResult = null;
|
||||
|
||||
if (cover != null && cover.isNotEmpty) {
|
||||
videoDetailCtr.cover.value = cover;
|
||||
}
|
||||
|
||||
// 重新请求相关视频
|
||||
if (videoDetailCtr.plPlayerController.showRelatedVideo) {
|
||||
try {
|
||||
Get.find<RelatedController>(tag: heroTag)
|
||||
..bvid = bvid
|
||||
..queryData();
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
// 重新请求评论
|
||||
if (videoDetailCtr.showReply) {
|
||||
try {
|
||||
Get.find<VideoReplyController>(tag: heroTag)
|
||||
..aid = aid
|
||||
..onReload();
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
hasLater.value = false;
|
||||
this.bvid = bvid;
|
||||
queryVideoIntro();
|
||||
}
|
||||
|
||||
this.cid.value = cid;
|
||||
queryOnlineTotal();
|
||||
} catch (e) {
|
||||
debugPrint('ugc onChangeEpisode: $e');
|
||||
}
|
||||
|
||||
videoDetailCtr
|
||||
..plPlayerController.pause()
|
||||
..makeHeartBeat()
|
||||
..updateMediaListHistory(aid)
|
||||
..onReset(isStein)
|
||||
..bvid = bvid
|
||||
..oid.value = aid ?? IdUtils.bv2av(bvid)
|
||||
..cid.value = cid
|
||||
..queryVideoUrl();
|
||||
|
||||
if (this.bvid != bvid) {
|
||||
reload = true;
|
||||
aiConclusionResult = null;
|
||||
|
||||
if (cover is String && cover.isNotEmpty) {
|
||||
videoDetailCtr.cover.value = cover;
|
||||
}
|
||||
|
||||
// 重新请求相关视频
|
||||
if (videoDetailCtr.plPlayerController.showRelatedVideo) {
|
||||
try {
|
||||
Get.find<RelatedController>(tag: heroTag)
|
||||
..bvid = bvid
|
||||
..queryData();
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
// 重新请求评论
|
||||
if (videoDetailCtr.showReply) {
|
||||
try {
|
||||
Get.find<VideoReplyController>(tag: heroTag)
|
||||
..aid = aid
|
||||
..onReload();
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
hasLater.value = false;
|
||||
this.bvid = bvid;
|
||||
queryVideoIntro();
|
||||
}
|
||||
|
||||
this.cid.value = cid;
|
||||
queryOnlineTotal();
|
||||
return true;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -538,7 +550,7 @@ class UgcIntroController extends CommonIntroController with ReloadMixin {
|
||||
/// 播放上一个
|
||||
@override
|
||||
bool prevPlay([bool skipPages = false]) {
|
||||
final List episodes = [];
|
||||
final List<BaseEpisodeItem> episodes = <BaseEpisodeItem>[];
|
||||
bool isPages = false;
|
||||
|
||||
final videoDetailCtr = Get.find<VideoDetailController>(tag: heroTag);
|
||||
@@ -566,7 +578,7 @@ class UgcIntroController extends CommonIntroController with ReloadMixin {
|
||||
? videoDetail.isPageReversed == true
|
||||
? videoDetail.pages!.last.cid
|
||||
: videoDetail.pages!.first.cid
|
||||
: this.cid.value),
|
||||
: cid.value),
|
||||
);
|
||||
int prevIndex = currentIndex - 1;
|
||||
final PlayRepeat playRepeat = videoDetailCtr.plPlayerController.playRepeat;
|
||||
@@ -583,10 +595,7 @@ class UgcIntroController extends CommonIntroController with ReloadMixin {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
final int cid = episodes[prevIndex].cid!;
|
||||
final String rBvid = isPages ? bvid : episodes[prevIndex].bvid;
|
||||
final int rAid = isPages ? IdUtils.bv2av(bvid) : episodes[prevIndex].aid!;
|
||||
onChangeEpisode(null, rBvid, cid, rAid, null);
|
||||
onChangeEpisode(episodes[prevIndex]);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -594,7 +603,7 @@ class UgcIntroController extends CommonIntroController with ReloadMixin {
|
||||
@override
|
||||
bool nextPlay([bool skipPages = false]) {
|
||||
try {
|
||||
final List episodes = [];
|
||||
final List<BaseEpisodeItem> episodes = <BaseEpisodeItem>[];
|
||||
bool isPages = false;
|
||||
final videoDetailCtr = Get.find<VideoDetailController>(tag: heroTag);
|
||||
final videoDetail = this.videoDetail.value;
|
||||
@@ -671,10 +680,7 @@ class UgcIntroController extends CommonIntroController with ReloadMixin {
|
||||
}
|
||||
cid = episodes[nextIndex].cid!;
|
||||
}
|
||||
|
||||
final String rBvid = isPages ? bvid : episodes[nextIndex].bvid;
|
||||
final int rAid = isPages ? IdUtils.bv2av(bvid) : episodes[nextIndex].aid!;
|
||||
onChangeEpisode(null, rBvid, cid, rAid, null);
|
||||
onChangeEpisode(episodes[nextIndex]);
|
||||
return true;
|
||||
} catch (_) {
|
||||
return false;
|
||||
@@ -703,29 +709,14 @@ class UgcIntroController extends CommonIntroController with ReloadMixin {
|
||||
}
|
||||
|
||||
final firstItem = relatedCtr.loadingState.value.data!.first;
|
||||
try {
|
||||
if (firstItem.cid != null) {
|
||||
onChangeEpisode(
|
||||
null,
|
||||
firstItem.bvid,
|
||||
firstItem.cid,
|
||||
firstItem.aid,
|
||||
firstItem.cover,
|
||||
);
|
||||
} else {
|
||||
SearchHttp.ab2c(aid: firstItem.aid, bvid: firstItem.bvid).then(
|
||||
(cid) => onChangeEpisode(
|
||||
null,
|
||||
firstItem.bvid,
|
||||
cid,
|
||||
firstItem.aid,
|
||||
firstItem.cover,
|
||||
),
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
SmartDialog.showToast(err.toString());
|
||||
}
|
||||
onChangeEpisode(
|
||||
BaseEpisodeItem(
|
||||
aid: firstItem.aid,
|
||||
bvid: firstItem.bvid,
|
||||
cid: firstItem.cid,
|
||||
cover: firstItem.cover,
|
||||
),
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -320,7 +320,6 @@ class _UgcIntroPanelState extends State<UgcIntroPanel>
|
||||
.horizontalSeasonPanel))
|
||||
SeasonPanel(
|
||||
heroTag: widget.heroTag,
|
||||
onChangeEpisode: ugcIntroController.onChangeEpisode,
|
||||
showEpisodes: widget.showEpisodes,
|
||||
ugcIntroController: ugcIntroController,
|
||||
),
|
||||
|
||||
@@ -156,13 +156,7 @@ class _PagesPanelState extends State<PagesPanel> {
|
||||
if (widget.showEpisodes == null) {
|
||||
Get.back();
|
||||
}
|
||||
widget.ugcIntroController.onChangeEpisode(
|
||||
null,
|
||||
widget.bvid,
|
||||
item.cid,
|
||||
IdUtils.bv2av(widget.bvid),
|
||||
widget.cover,
|
||||
);
|
||||
widget.ugcIntroController.onChangeEpisode(item);
|
||||
if (widget.list != null &&
|
||||
widget
|
||||
.ugcIntroController
|
||||
|
||||
@@ -11,13 +11,11 @@ import 'package:get/get.dart';
|
||||
class SeasonPanel extends StatefulWidget {
|
||||
const SeasonPanel({
|
||||
super.key,
|
||||
required this.onChangeEpisode,
|
||||
required this.heroTag,
|
||||
required this.showEpisodes,
|
||||
this.onTap,
|
||||
required this.ugcIntroController,
|
||||
});
|
||||
final Function onChangeEpisode;
|
||||
final String heroTag;
|
||||
final Function showEpisodes;
|
||||
final bool? onTap;
|
||||
|
||||
Reference in New Issue
Block a user