feat: 顺序播放
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
class MediaVideoItemModel {
|
class MediaVideoItemModel {
|
||||||
MediaVideoItemModel({
|
MediaVideoItemModel({
|
||||||
this.id,
|
this.id,
|
||||||
|
this.aid,
|
||||||
this.offset,
|
this.offset,
|
||||||
this.index,
|
this.index,
|
||||||
this.intro,
|
this.intro,
|
||||||
@ -14,12 +15,13 @@ class MediaVideoItemModel {
|
|||||||
this.likeState,
|
this.likeState,
|
||||||
this.favState,
|
this.favState,
|
||||||
this.page,
|
this.page,
|
||||||
|
this.cid,
|
||||||
this.pages,
|
this.pages,
|
||||||
this.title,
|
this.title,
|
||||||
this.type,
|
this.type,
|
||||||
this.upper,
|
this.upper,
|
||||||
this.link,
|
this.link,
|
||||||
this.bvId,
|
this.bvid,
|
||||||
this.shortLink,
|
this.shortLink,
|
||||||
this.rights,
|
this.rights,
|
||||||
this.elecInfo,
|
this.elecInfo,
|
||||||
@ -32,6 +34,7 @@ class MediaVideoItemModel {
|
|||||||
});
|
});
|
||||||
|
|
||||||
int? id;
|
int? id;
|
||||||
|
int? aid;
|
||||||
int? offset;
|
int? offset;
|
||||||
int? index;
|
int? index;
|
||||||
String? intro;
|
String? intro;
|
||||||
@ -45,12 +48,13 @@ class MediaVideoItemModel {
|
|||||||
int? likeState;
|
int? likeState;
|
||||||
int? favState;
|
int? favState;
|
||||||
int? page;
|
int? page;
|
||||||
|
int? cid;
|
||||||
List<Page>? pages;
|
List<Page>? pages;
|
||||||
String? title;
|
String? title;
|
||||||
int? type;
|
int? type;
|
||||||
Upper? upper;
|
Upper? upper;
|
||||||
String? link;
|
String? link;
|
||||||
String? bvId;
|
String? bvid;
|
||||||
String? shortLink;
|
String? shortLink;
|
||||||
Rights? rights;
|
Rights? rights;
|
||||||
dynamic elecInfo;
|
dynamic elecInfo;
|
||||||
@ -64,6 +68,7 @@ class MediaVideoItemModel {
|
|||||||
factory MediaVideoItemModel.fromJson(Map<String, dynamic> json) =>
|
factory MediaVideoItemModel.fromJson(Map<String, dynamic> json) =>
|
||||||
MediaVideoItemModel(
|
MediaVideoItemModel(
|
||||||
id: json["id"],
|
id: json["id"],
|
||||||
|
aid: json["id"],
|
||||||
offset: json["offset"],
|
offset: json["offset"],
|
||||||
index: json["index"],
|
index: json["index"],
|
||||||
intro: json["intro"],
|
intro: json["intro"],
|
||||||
@ -77,6 +82,7 @@ class MediaVideoItemModel {
|
|||||||
likeState: json["like_state"],
|
likeState: json["like_state"],
|
||||||
favState: json["fav_state"],
|
favState: json["fav_state"],
|
||||||
page: json["page"],
|
page: json["page"],
|
||||||
|
cid: json["pages"] == null ? -1 : json["pages"].first['id'],
|
||||||
// json["pages"] 可能为null
|
// json["pages"] 可能为null
|
||||||
pages: json["pages"] == null
|
pages: json["pages"] == null
|
||||||
? []
|
? []
|
||||||
@ -85,7 +91,7 @@ class MediaVideoItemModel {
|
|||||||
type: json["type"],
|
type: json["type"],
|
||||||
upper: Upper.fromJson(json["upper"]),
|
upper: Upper.fromJson(json["upper"]),
|
||||||
link: json["link"],
|
link: json["link"],
|
||||||
bvId: json["bv_id"],
|
bvid: json["bv_id"],
|
||||||
shortLink: json["short_link"],
|
shortLink: json["short_link"],
|
||||||
rights: Rights.fromJson(json["rights"]),
|
rights: Rights.fromJson(json["rights"]),
|
||||||
elecInfo: json["elec_info"],
|
elecInfo: json["elec_info"],
|
||||||
|
@ -411,7 +411,12 @@ class VideoIntroController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改分P或番剧分集
|
// 修改分P或番剧分集
|
||||||
Future changeSeasonOrbangu(bvid, cid, aid, cover) async {
|
Future changeSeasonOrbangu(
|
||||||
|
String bvid,
|
||||||
|
int cid,
|
||||||
|
int? aid,
|
||||||
|
String? cover,
|
||||||
|
) async {
|
||||||
// 重新获取视频资源
|
// 重新获取视频资源
|
||||||
final VideoDetailController videoDetailCtr =
|
final VideoDetailController videoDetailCtr =
|
||||||
Get.find<VideoDetailController>(tag: heroTag);
|
Get.find<VideoDetailController>(tag: heroTag);
|
||||||
@ -422,13 +427,14 @@ class VideoIntroController extends GetxController {
|
|||||||
releatedCtr.queryRelatedVideo();
|
releatedCtr.queryRelatedVideo();
|
||||||
}
|
}
|
||||||
|
|
||||||
videoDetailCtr.bvid = bvid;
|
videoDetailCtr
|
||||||
videoDetailCtr.oid.value = aid ?? IdUtils.bv2av(bvid);
|
..bvid = bvid
|
||||||
videoDetailCtr.cid.value = cid;
|
..oid.value = aid ?? IdUtils.bv2av(bvid)
|
||||||
videoDetailCtr.danmakuCid.value = cid;
|
..cid.value = cid
|
||||||
videoDetailCtr.cover.value = cover;
|
..danmakuCid.value = cid
|
||||||
videoDetailCtr.queryVideoUrl();
|
..cover.value = cover ?? ''
|
||||||
videoDetailCtr.clearSubtitleContent();
|
..queryVideoUrl()
|
||||||
|
..clearSubtitleContent();
|
||||||
await videoDetailCtr.getSubtitle();
|
await videoDetailCtr.getSubtitle();
|
||||||
videoDetailCtr.setSubtitleContent();
|
videoDetailCtr.setSubtitleContent();
|
||||||
// 重新请求评论
|
// 重新请求评论
|
||||||
@ -478,7 +484,13 @@ class VideoIntroController extends GetxController {
|
|||||||
final List episodes = [];
|
final List episodes = [];
|
||||||
bool isPages = false;
|
bool isPages = false;
|
||||||
late String cover;
|
late String cover;
|
||||||
if (videoDetail.value.ugcSeason != null) {
|
final VideoDetailController videoDetailCtr =
|
||||||
|
Get.find<VideoDetailController>(tag: heroTag);
|
||||||
|
|
||||||
|
/// 优先稍后再看、收藏夹
|
||||||
|
if (videoDetailCtr.isWatchLaterVisible.value) {
|
||||||
|
episodes.addAll(videoDetailCtr.mediaList);
|
||||||
|
} 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++) {
|
||||||
@ -495,10 +507,15 @@ class VideoIntroController extends GetxController {
|
|||||||
episodes.indexWhere((e) => e.cid == lastPlayCid.value);
|
episodes.indexWhere((e) => e.cid == lastPlayCid.value);
|
||||||
int nextIndex = currentIndex + 1;
|
int nextIndex = currentIndex + 1;
|
||||||
cover = episodes[nextIndex].cover;
|
cover = episodes[nextIndex].cover;
|
||||||
final VideoDetailController videoDetailCtr =
|
|
||||||
Get.find<VideoDetailController>(tag: heroTag);
|
|
||||||
final PlayRepeat platRepeat = videoDetailCtr.plPlayerController.playRepeat;
|
final PlayRepeat platRepeat = videoDetailCtr.plPlayerController.playRepeat;
|
||||||
|
|
||||||
|
int cid = episodes[nextIndex].cid!;
|
||||||
|
while (cid == -1) {
|
||||||
|
nextIndex += 1;
|
||||||
|
SmartDialog.showToast('当前视频暂不支持播放,自动跳过');
|
||||||
|
cid = episodes[nextIndex].cid!;
|
||||||
|
}
|
||||||
|
|
||||||
// 列表循环
|
// 列表循环
|
||||||
if (nextIndex >= episodes.length) {
|
if (nextIndex >= episodes.length) {
|
||||||
if (platRepeat == PlayRepeat.listCycle) {
|
if (platRepeat == PlayRepeat.listCycle) {
|
||||||
@ -508,7 +525,6 @@ class VideoIntroController extends GetxController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final int cid = episodes[nextIndex].cid!;
|
|
||||||
final String rBvid = isPages ? bvid : episodes[nextIndex].bvid;
|
final String rBvid = isPages ? bvid : episodes[nextIndex].bvid;
|
||||||
final int rAid = isPages ? IdUtils.bv2av(bvid) : episodes[nextIndex].aid!;
|
final int rAid = isPages ? IdUtils.bv2av(bvid) : episodes[nextIndex].aid!;
|
||||||
changeSeasonOrbangu(rBvid, cid, rAid, cover);
|
changeSeasonOrbangu(rBvid, cid, rAid, cover);
|
||||||
|
@ -109,7 +109,7 @@ class _MediaListPanelState extends State<MediaListPanel> {
|
|||||||
var item = mediaList[index];
|
var item = mediaList[index];
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
String bvid = item.bvId!;
|
String bvid = item.bvid!;
|
||||||
int? aid = item.id;
|
int? aid = item.id;
|
||||||
String cover = item.cover ?? '';
|
String cover = item.cover ?? '';
|
||||||
final int cid =
|
final int cid =
|
||||||
@ -173,7 +173,7 @@ class _MediaListPanelState extends State<MediaListPanel> {
|
|||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.w500,
|
fontWeight: FontWeight.w500,
|
||||||
color: item.bvId == widget.bvid
|
color: item.bvid == widget.bvid
|
||||||
? Theme.of(context)
|
? Theme.of(context)
|
||||||
.colorScheme
|
.colorScheme
|
||||||
.primary
|
.primary
|
||||||
|
Reference in New Issue
Block a user