mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
feat: season: reverse play #70
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -127,6 +127,7 @@ class _BangumiPanelState extends State<BangumiPanel> {
|
||||
widget.pages[currentIndex].bvid,
|
||||
widget.pages[currentIndex].aid,
|
||||
cid,
|
||||
null,
|
||||
),
|
||||
child: Text(
|
||||
widget.newEp?['desc']?.contains('连载') == true
|
||||
|
||||
@@ -11,7 +11,6 @@ import 'package:PiliPalaX/http/init.dart';
|
||||
import 'package:PiliPalaX/http/user.dart';
|
||||
import 'package:PiliPalaX/models/video/later.dart';
|
||||
import 'package:PiliPalaX/models/video/play/subtitle.dart';
|
||||
import 'package:PiliPalaX/models/video_detail_res.dart';
|
||||
import 'package:PiliPalaX/pages/video/detail/introduction/controller.dart';
|
||||
import 'package:PiliPalaX/pages/video/detail/related/controller.dart';
|
||||
import 'package:PiliPalaX/pages/video/detail/reply/controller.dart';
|
||||
@@ -225,7 +224,6 @@ class VideoDetailController extends GetxController
|
||||
late final horizontalSeasonPanel = GStorage.horizontalSeasonPanel;
|
||||
late int seasonCid = 0;
|
||||
late RxInt seasonIndex = 0.obs;
|
||||
late RxList<EpisodeItem> episodes = <EpisodeItem>[].obs;
|
||||
|
||||
late final bool enableSponsorBlock;
|
||||
PlayerStatus? playerStatus;
|
||||
|
||||
@@ -127,10 +127,13 @@ class VideoIntroController extends GetxController
|
||||
|
||||
// 获取视频简介&分p
|
||||
Future queryVideoIntro() async {
|
||||
await queryVideoTags();
|
||||
queryVideoTags();
|
||||
var result = await VideoHttp.videoIntro(bvid: bvid);
|
||||
if (result['status']) {
|
||||
videoDetail.value = result['data']!;
|
||||
if (videoDetail.value.ugcSeason?.id == result['data']?.ugcSeason?.id) {
|
||||
result['data']?.ugcSeason = videoDetail.value.ugcSeason;
|
||||
}
|
||||
videoDetail.value = result['data'];
|
||||
videoItem!['staff'] = result['data'].staff;
|
||||
try {
|
||||
final videoDetailController =
|
||||
|
||||
@@ -102,6 +102,7 @@ class _PagesPanelState extends State<PagesPanel> {
|
||||
widget.bvid,
|
||||
IdUtils.bv2av(widget.bvid),
|
||||
cid,
|
||||
null,
|
||||
),
|
||||
child: Text(
|
||||
'共${widget.pages.length}集',
|
||||
|
||||
@@ -32,6 +32,7 @@ class _SeasonPanelState extends State<SeasonPanel> {
|
||||
int currentIndex = 0;
|
||||
late VideoDetailController _videoDetailController;
|
||||
StreamSubscription? _listener;
|
||||
List<EpisodeItem> episodes = <EpisodeItem>[];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -43,7 +44,7 @@ class _SeasonPanelState extends State<SeasonPanel> {
|
||||
/// 根据 cid 找到对应集,找到对应 episodes
|
||||
/// 有多个episodes时,只显示其中一个
|
||||
_findEpisode();
|
||||
if (_videoDetailController.episodes.isEmpty) {
|
||||
if (episodes.isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -51,14 +52,16 @@ class _SeasonPanelState extends State<SeasonPanel> {
|
||||
// episodes = widget.ugcSeason.sections!
|
||||
// .firstWhere((e) => e.seasonId == widget.ugcSeason.id)
|
||||
// .episodes;
|
||||
currentIndex = _videoDetailController.episodes.indexWhere(
|
||||
currentIndex = episodes.indexWhere(
|
||||
(EpisodeItem e) => e.cid == _videoDetailController.seasonCid);
|
||||
_listener = _videoDetailController.cid.listen((int p0) {
|
||||
bool isPart = widget.pages?.indexWhere((item) => item.cid == p0) != -1;
|
||||
if (isPart) return;
|
||||
if (widget.pages != null && widget.pages!.length != 1) {
|
||||
bool isPart = widget.pages?.indexWhere((item) => item.cid == p0) != -1;
|
||||
if (isPart) return;
|
||||
}
|
||||
_videoDetailController.seasonCid = p0;
|
||||
_findEpisode();
|
||||
currentIndex = _videoDetailController.episodes.indexWhere(
|
||||
currentIndex = episodes.indexWhere(
|
||||
(EpisodeItem e) => e.cid == _videoDetailController.seasonCid);
|
||||
if (!mounted) return;
|
||||
setState(() {});
|
||||
@@ -84,7 +87,7 @@ class _SeasonPanelState extends State<SeasonPanel> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (_videoDetailController.episodes.isEmpty) {
|
||||
if (episodes.isEmpty) {
|
||||
return const SizedBox();
|
||||
}
|
||||
return Builder(builder: (BuildContext context) {
|
||||
@@ -105,10 +108,15 @@ class _SeasonPanelState extends State<SeasonPanel> {
|
||||
: () => widget.showEpisodes(
|
||||
_videoDetailController.seasonIndex.value,
|
||||
widget.ugcSeason,
|
||||
_videoDetailController.episodes,
|
||||
null,
|
||||
_videoDetailController.bvid,
|
||||
null,
|
||||
_videoDetailController.seasonCid,
|
||||
() {
|
||||
setState(() {
|
||||
currentIndex = episodes.length - 1 - currentIndex;
|
||||
});
|
||||
},
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.fromLTRB(8, 12, 8, 12),
|
||||
@@ -130,10 +138,10 @@ class _SeasonPanelState extends State<SeasonPanel> {
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Text(
|
||||
'${currentIndex + 1}/${_videoDetailController.episodes.length}',
|
||||
'${currentIndex + 1}/${episodes.length}',
|
||||
style: Theme.of(context).textTheme.labelMedium,
|
||||
semanticsLabel:
|
||||
'第${currentIndex + 1}集,共${_videoDetailController.episodes.length}集',
|
||||
'第${currentIndex + 1}集,共${episodes.length}集',
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
const Icon(
|
||||
@@ -156,8 +164,10 @@ class _SeasonPanelState extends State<SeasonPanel> {
|
||||
final List<EpisodeItem> episodesList = sections[i].episodes!;
|
||||
for (int j = 0; j < episodesList.length; j++) {
|
||||
if (episodesList[j].cid == _videoDetailController.seasonCid) {
|
||||
_videoDetailController.seasonIndex.value = i;
|
||||
_videoDetailController.episodes.value = episodesList;
|
||||
if (_videoDetailController.seasonIndex.value != i) {
|
||||
_videoDetailController.seasonIndex.value = i;
|
||||
}
|
||||
episodes = episodesList;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1505,8 +1505,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
child: Obx(
|
||||
() => ListSheetContent(
|
||||
index: videoDetailController.seasonIndex.value,
|
||||
season: videoIntroController.videoDetail.value.ugcSeason!,
|
||||
episodes: videoDetailController.episodes,
|
||||
season: videoIntroController.videoDetail.value.ugcSeason,
|
||||
bvid: videoDetailController.bvid,
|
||||
aid: IdUtils.bv2av(videoDetailController.bvid),
|
||||
currentCid: videoDetailController.seasonCid,
|
||||
@@ -1514,6 +1513,8 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
SearchType.media_bangumi
|
||||
? bangumiIntroController.changeSeasonOrbangu
|
||||
: videoIntroController.changeSeasonOrbangu,
|
||||
showTitle: false,
|
||||
onReverse: onReversePlay,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -1576,14 +1577,14 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
);
|
||||
}
|
||||
|
||||
showEpisodes(index, season, episodes, bvid, aid, cid) {
|
||||
showEpisodes(index, season, episodes, bvid, aid, cid, onReverse) {
|
||||
Widget listSheetContent() => ListSheetContent(
|
||||
index: index,
|
||||
season: season,
|
||||
episodes: episodes,
|
||||
bvid: bvid,
|
||||
aid: aid,
|
||||
currentCid: cid,
|
||||
episodes: episodes,
|
||||
changeFucCall:
|
||||
videoDetailController.videoType == SearchType.media_bangumi
|
||||
? bangumiIntroController.changeSeasonOrbangu
|
||||
@@ -1596,6 +1597,11 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
Get.back();
|
||||
}
|
||||
},
|
||||
onReverse: () {
|
||||
Get.back();
|
||||
onReversePlay();
|
||||
onReverse();
|
||||
},
|
||||
);
|
||||
if (isFullScreen) {
|
||||
videoDetailController.bsController =
|
||||
@@ -1609,6 +1615,21 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
}
|
||||
}
|
||||
|
||||
void onReversePlay() {
|
||||
videoIntroController.videoDetail.value.ugcSeason!
|
||||
.sections![videoDetailController.seasonIndex.value].episodes =
|
||||
videoIntroController
|
||||
.videoDetail
|
||||
.value
|
||||
.ugcSeason!
|
||||
.sections![videoDetailController.seasonIndex.value]
|
||||
.episodes!
|
||||
.reversed
|
||||
.toList();
|
||||
videoDetailController.seasonIndex.refresh();
|
||||
videoDetailController.cid.refresh();
|
||||
}
|
||||
|
||||
void showViewPoints() {
|
||||
Widget listSheetContent(context, [bool isFS = false]) {
|
||||
int currentIndex = -1;
|
||||
|
||||
Reference in New Issue
Block a user