feat: 稍后再看&收藏夹播放全部

Co-authored-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
guozhigq
2024-09-21 15:14:38 +08:00
committed by bggRGjQaUbCoE
parent 47241897de
commit 9e8d34e0dc
13 changed files with 874 additions and 42 deletions

View File

@@ -0,0 +1,225 @@
import 'package:PiliPalaX/common/widgets/stat/danmu.dart';
import 'package:PiliPalaX/common/widgets/stat/view.dart';
import 'package:PiliPalaX/utils/extension.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:PiliPalaX/common/constants.dart';
import 'package:PiliPalaX/common/widgets/badge.dart';
import 'package:PiliPalaX/common/widgets/network_img_layer.dart';
import 'package:PiliPalaX/http/search.dart';
import 'package:PiliPalaX/http/user.dart';
import 'package:PiliPalaX/models/video/later.dart';
import 'package:PiliPalaX/utils/utils.dart';
class MediaListPanel extends StatefulWidget {
const MediaListPanel({
this.sheetHeight,
required this.mediaList,
this.changeMediaList,
this.panelTitle,
this.bvid,
this.mediaId,
this.hasMore = false,
super.key,
});
final double? sheetHeight;
final List<MediaVideoItemModel> mediaList;
final Function? changeMediaList;
final String? panelTitle;
final String? bvid;
final int? mediaId;
final bool hasMore;
@override
State<MediaListPanel> createState() => _MediaListPanelState();
}
class _MediaListPanelState extends State<MediaListPanel> {
RxList<MediaVideoItemModel> mediaList = <MediaVideoItemModel>[].obs;
bool _isEnd = false;
@override
void initState() {
super.initState();
mediaList.value = widget.mediaList;
}
void loadMore() async {
var res = await UserHttp.getMediaList(
type: 3,
bizId: widget.mediaId!,
ps: 20,
oid: mediaList.last.id,
);
if (res['status']) {
if (res['data'].isNotEmpty) {
mediaList.addAll(res['data']);
} else {
_isEnd = true;
}
} else {
SmartDialog.showToast(res['msg']);
}
}
@override
Widget build(BuildContext context) {
return DecoratedBox(
decoration: BoxDecoration(
color: Theme.of(context).colorScheme.surface,
),
child: Column(
children: [
AppBar(
toolbarHeight: 45,
automaticallyImplyLeading: false,
titleSpacing: 16,
title: Text(widget.panelTitle ?? '稍后再看'),
actions: [
IconButton(
icon: const Icon(Icons.close, size: 20),
onPressed: Get.back,
),
const SizedBox(width: 14),
],
),
Expanded(
child: Material(
color: Theme.of(context).colorScheme.surface,
child: Obx(
() => ListView.builder(
itemCount: mediaList.length,
itemBuilder: ((context, index) {
var item = mediaList[index];
if (index == widget.mediaList.length - 1 && _isEnd.not) {
loadMore();
}
return InkWell(
onTap: () async {
Get.back();
String bvid = item.bvid!;
int? aid = item.id;
String cover = item.cover ?? '';
final int cid =
await SearchHttp.ab2c(aid: aid, bvid: bvid);
widget.changeMediaList?.call(bvid, cid, aid, cover);
},
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 10,
vertical: 8,
),
child: LayoutBuilder(
builder: (context, boxConstraints) {
const double width = 120;
return Container(
constraints: const BoxConstraints(minHeight: 88),
height: width / StyleString.aspectRatio,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
AspectRatio(
aspectRatio: StyleString.aspectRatio,
child: LayoutBuilder(
builder: (BuildContext context,
BoxConstraints boxConstraints) {
final double maxWidth =
boxConstraints.maxWidth;
final double maxHeight =
boxConstraints.maxHeight;
return Stack(
children: [
NetworkImgLayer(
src: item.cover ?? '',
width: maxWidth,
height: maxHeight,
),
PBadge(
text: Utils.timeFormat(
item.duration!),
right: 6.0,
bottom: 6.0,
type: 'gray',
),
],
);
},
),
),
Expanded(
child: Padding(
padding: const EdgeInsets.fromLTRB(
10, 0, 6, 0),
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
item.title as String,
textAlign: TextAlign.start,
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontWeight: FontWeight.w500,
color: item.bvid == widget.bvid
? Theme.of(context)
.colorScheme
.primary
: null,
),
),
const Spacer(),
Text(
item.upper?.name as String,
style: TextStyle(
fontSize: Theme.of(context)
.textTheme
.labelMedium!
.fontSize,
color: Theme.of(context)
.colorScheme
.outline,
),
),
const SizedBox(height: 2),
Row(
children: [
statView(
context: context,
theme: 'gray',
view: item.cntInfo!['play']
as int,
),
const SizedBox(width: 8),
statDanMu(
context: context,
theme: 'gray',
danmu: item.cntInfo!['danmaku']
as int,
),
],
),
],
),
),
)
],
),
);
},
),
),
);
}),
),
),
),
),
],
),
);
}
}

View File

@@ -693,4 +693,7 @@ class Api {
static const String videoRelation = '/x/web-interface/archive/relation';
static const String seasonFav = '/x/v3/fav/season/'; // + fav unfav
/// 稍后再看&收藏夹视频列表
static const String mediaList = '/x/v2/medialist/resource/list';
}

View File

@@ -1,6 +1,10 @@
import 'dart:convert';
import 'package:PiliPalaX/http/loading_state.dart';
import 'package:PiliPalaX/models/video/later.dart';
import 'package:dio/dio.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:html/parser.dart';
import '../common/constants.dart';
import '../models/model_hot_video_item.dart';
import '../models/user/fav_detail.dart';
@@ -471,4 +475,105 @@ class UserHttp {
return {'status': false};
}
}
// 稍后再看播放全部
// static Future toViewPlayAll({required int oid, required String bvid}) async {
// var res = await Request().get(
// Api.watchLaterHtml,
// data: {
// 'oid': oid,
// 'bvid': bvid,
// },
// );
// String scriptContent =
// extractScriptContents(parse(res.data).body!.outerHtml)[0];
// int startIndex = scriptContent.indexOf('{');
// int endIndex = scriptContent.lastIndexOf('};');
// String jsonContent = scriptContent.substring(startIndex, endIndex + 1);
// // 解析JSON字符串为Map
// Map<String, dynamic> jsonData = json.decode(jsonContent);
// // 输出解析后的数据
// return {
// 'status': true,
// 'data': jsonData['resourceList']
// .map((e) => MediaVideoItemModel.fromJson(e))
// .toList()
// };
// }
static List<String> extractScriptContents(String htmlContent) {
RegExp scriptRegExp = RegExp(r'<script>([\s\S]*?)<\/script>');
Iterable<Match> matches = scriptRegExp.allMatches(htmlContent);
List<String> scriptContents = [];
for (Match match in matches) {
String scriptContent = match.group(1)!;
scriptContents.add(scriptContent);
}
return scriptContents;
}
// 稍后再看列表
static Future getMediaList({
required int type,
required int bizId,
required int ps,
int? oid,
}) async {
var res = await Request().get(
Api.mediaList,
queryParameters: {
'mobi_app': 'web',
'type': type,
'biz_id': bizId,
'oid': oid ?? '',
'otype': 2,
'ps': ps,
'direction': false,
'desc': true,
'sort_field': 1,
'tid': 0,
'with_current': false,
},
);
if (res.data['code'] == 0) {
return {
'status': true,
'data': res.data['data']['media_list'] != null
? res.data['data']['media_list']
.map<MediaVideoItemModel>(
(e) => MediaVideoItemModel.fromJson(e))
.toList()
: []
};
} else {
return {'status': false, 'msg': res.data['message']};
}
}
// 解析收藏夹视频
static Future parseFavVideo({
required int mediaId,
required int oid,
required String bvid,
}) async {
var res = await Request().get(
'https://www.bilibili.com/list/ml$mediaId',
queryParameters: {
'oid': mediaId,
'bvid': bvid,
},
);
String scriptContent =
extractScriptContents(parse(res.data).body!.outerHtml)[0];
int startIndex = scriptContent.indexOf('{');
int endIndex = scriptContent.lastIndexOf('};');
String jsonContent = scriptContent.substring(startIndex, endIndex + 1);
// 解析JSON字符串为Map
Map<String, dynamic> jsonData = json.decode(jsonContent);
return {
'status': true,
'data': jsonData['resourceList']
.map<MediaVideoItemModel>((e) => MediaVideoItemModel.fromJson(e))
.toList()
};
}
}

277
lib/models/video/later.dart Normal file
View File

@@ -0,0 +1,277 @@
class MediaVideoItemModel {
MediaVideoItemModel({
this.id,
this.aid,
this.bvid,
this.cid,
this.offset,
this.index,
this.intro,
this.attr,
this.tid,
this.copyRight,
this.cntInfo,
this.cover,
this.duration,
this.pubtime,
this.likeState,
this.favState,
this.page,
this.pages,
this.title,
this.type,
this.upper,
this.link,
this.shortLink,
this.rights,
this.elecInfo,
this.coin,
this.progressPercent,
this.badge,
this.forbidFav,
this.moreType,
this.businessOid,
});
int? id;
int? aid;
String? bvid;
int? cid;
int? offset;
int? index;
String? intro;
int? attr;
int? tid;
int? copyRight;
Map? cntInfo;
String? cover;
int? duration;
int? pubtime;
int? likeState;
int? favState;
int? page;
List<Page>? pages;
String? title;
int? type;
Upper? upper;
String? link;
String? bvId;
String? shortLink;
Rights? rights;
dynamic elecInfo;
Coin? coin;
double? progressPercent;
dynamic badge;
bool? forbidFav;
int? moreType;
int? businessOid;
factory MediaVideoItemModel.fromJson(Map<String, dynamic> json) =>
MediaVideoItemModel(
id: json["id"],
aid: json["id"],
bvid: json["bv_id"],
cid: json["pages"] == null ? -1 : json["pages"].first['id'],
offset: json["offset"],
index: json["index"],
intro: json["intro"],
attr: json["attr"],
tid: json["tid"],
copyRight: json["copy_right"],
cntInfo: json["cnt_info"],
cover: json["cover"],
duration: json["duration"],
pubtime: json["pubtime"],
likeState: json["like_state"],
favState: json["fav_state"],
page: json["page"],
// json["pages"] 可能为null
pages: json["pages"] == null
? []
: List<Page>.from(json["pages"].map((x) => Page.fromJson(x))),
title: json["title"],
type: json["type"],
upper: Upper.fromJson(json["upper"]),
link: json["link"],
shortLink: json["short_link"],
rights: Rights.fromJson(json["rights"]),
elecInfo: json["elec_info"],
coin: Coin.fromJson(json["coin"]),
progressPercent: json["progress_percent"].toDouble(),
badge: json["badge"],
forbidFav: json["forbid_fav"],
moreType: json["more_type"],
businessOid: json["business_oid"],
);
}
class Coin {
Coin({
this.maxNum,
this.coinNumber,
});
int? maxNum;
int? coinNumber;
factory Coin.fromJson(Map<String, dynamic> json) => Coin(
maxNum: json["max_num"],
coinNumber: json["coin_number"],
);
}
class Page {
Page({
this.id,
this.title,
this.intro,
this.duration,
this.link,
this.page,
this.metas,
this.from,
this.dimension,
});
int? id;
String? title;
String? intro;
int? duration;
String? link;
int? page;
List<Meta>? metas;
String? from;
Dimension? dimension;
factory Page.fromJson(Map<String, dynamic> json) => Page(
id: json["id"],
title: json["title"],
intro: json["intro"],
duration: json["duration"],
link: json["link"],
page: json["page"],
metas: List<Meta>.from(json["metas"].map((x) => Meta.fromJson(x))),
from: json["from"],
dimension: Dimension.fromJson(json["dimension"]),
);
}
class Dimension {
Dimension({
this.width,
this.height,
this.rotate,
});
int? width;
int? height;
int? rotate;
factory Dimension.fromJson(Map<String, dynamic> json) => Dimension(
width: json["width"],
height: json["height"],
rotate: json["rotate"],
);
}
class Meta {
Meta({
this.quality,
this.size,
});
int? quality;
int? size;
factory Meta.fromJson(Map<String, dynamic> json) => Meta(
quality: json["quality"],
size: json["size"],
);
}
class Rights {
Rights({
this.bp,
this.elec,
this.download,
this.movie,
this.pay,
this.ugcPay,
this.hd5,
this.noReprint,
this.autoplay,
this.noBackground,
});
int? bp;
int? elec;
int? download;
int? movie;
int? pay;
int? ugcPay;
int? hd5;
int? noReprint;
int? autoplay;
int? noBackground;
factory Rights.fromJson(Map<String, dynamic> json) => Rights(
bp: json["bp"],
elec: json["elec"],
download: json["download"],
movie: json["movie"],
pay: json["pay"],
ugcPay: json["ugc_pay"],
hd5: json["hd5"],
noReprint: json["no_reprint"],
autoplay: json["autoplay"],
noBackground: json["no_background"],
);
}
class Upper {
Upper({
this.mid,
this.name,
this.face,
this.followed,
this.fans,
this.vipType,
this.vipStatue,
this.vipDueDate,
this.vipPayType,
this.officialRole,
this.officialTitle,
this.officialDesc,
this.displayName,
});
int? mid;
String? name;
String? face;
int? followed;
int? fans;
int? vipType;
int? vipStatue;
int? vipDueDate;
int? vipPayType;
int? officialRole;
String? officialTitle;
String? officialDesc;
String? displayName;
factory Upper.fromJson(Map<String, dynamic> json) => Upper(
mid: json["mid"],
name: json["name"],
face: json["face"],
followed: json["followed"],
fans: json["fans"],
vipType: json["vip_type"],
vipStatue: json["vip_statue"],
vipDueDate: json["vip_due_date"],
vipPayType: json["vip_pay_type"],
officialRole: json["official_role"],
officialTitle: json["official_title"],
officialDesc: json["official_desc"],
displayName: json["display_name"],
);
}

View File

@@ -4,6 +4,7 @@ import 'package:PiliPalaX/models/user/fav_detail.dart';
import 'package:PiliPalaX/models/user/fav_folder.dart';
import 'package:PiliPalaX/pages/common/multi_select_controller.dart';
import 'package:PiliPalaX/utils/storage.dart';
import 'package:PiliPalaX/utils/utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
@@ -123,4 +124,25 @@ class FavDetailController extends MultiSelectController {
},
);
}
Future toViewPlayAll() async {
if (loadingState.value is Success) {
final FavDetailItemData firstItem =
(loadingState.value as Success).response.first;
final String heroTag = Utils.makeHeroTag(firstItem.bvid);
Get.toNamed(
'/video?bvid=${firstItem.bvid}&cid=${firstItem.cid}',
arguments: {
'videoItem': firstItem,
'heroTag': heroTag,
'sourceType': 'fav',
'mediaId': item.value.id,
'oid': firstItem.id,
'favTitle': item.value.title,
// 'favInfo': favInfo,
'count': item.value.mediaCount,
},
);
}
}
}

View File

@@ -60,6 +60,15 @@ class _FavDetailPageState extends State<FavDetailPage> {
}
},
child: Scaffold(
floatingActionButton: Obx(
() => (_favDetailController.item.value.mediaCount ?? -1) > 0
? FloatingActionButton.extended(
onPressed: _favDetailController.toViewPlayAll,
label: const Text('播放全部'),
icon: const Icon(Icons.playlist_play),
)
: const SizedBox.shrink(),
),
body: CustomScrollView(
physics: const AlwaysScrollableScrollPhysics(),
controller: _favDetailController.scrollController,

View File

@@ -1,6 +1,7 @@
import 'package:PiliPalaX/http/loading_state.dart';
import 'package:PiliPalaX/models/model_hot_video_item.dart';
import 'package:PiliPalaX/pages/common/multi_select_controller.dart';
import 'package:PiliPalaX/utils/utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
@@ -162,4 +163,22 @@ class LaterController extends MultiSelectController {
SmartDialog.dismiss();
SmartDialog.showToast(res['msg']);
}
// 稍后再看播放全部
Future toViewPlayAll() async {
if (loadingState.value is Success) {
final HotVideoItemModel firstItem =
(loadingState.value as Success).response.first;
final String heroTag = Utils.makeHeroTag(firstItem.bvid);
Get.toNamed(
'/video?bvid=${firstItem.bvid}&cid=${firstItem.cid}',
arguments: {
'videoItem': firstItem,
'heroTag': heroTag,
'sourceType': 'watchLater',
'count': (loadingState.value as Success).response.length,
},
);
}
}
}

View File

@@ -95,6 +95,15 @@ class _LaterPageState extends State<LaterPage> {
],
),
),
floatingActionButton: Obx(
() => _laterController.loadingState.value is Success
? FloatingActionButton.extended(
onPressed: _laterController.toViewPlayAll,
label: const Text('播放全部'),
icon: const Icon(Icons.playlist_play),
)
: const SizedBox(),
),
body: CustomScrollView(
physics: const AlwaysScrollableScrollPhysics(),
controller: _laterController.scrollController,

View File

@@ -6,9 +6,15 @@ import 'package:PiliPalaX/common/widgets/icon_button.dart';
import 'package:PiliPalaX/common/widgets/loading_widget.dart';
import 'package:PiliPalaX/common/widgets/pair.dart';
import 'package:PiliPalaX/common/widgets/segment_progress_bar.dart';
import 'package:PiliPalaX/common/widgets/watch_later_list.dart';
import 'package:PiliPalaX/http/danmaku.dart';
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/pages/video/detail/introduction/controller.dart';
import 'package:PiliPalaX/pages/video/detail/related/controller.dart';
import 'package:PiliPalaX/pages/video/detail/reply/controller.dart';
import 'package:PiliPalaX/utils/extension.dart';
import 'package:canvas_danmaku/models/danmaku_content_item.dart';
import 'package:dio/dio.dart';
@@ -226,6 +232,11 @@ class VideoDetailController extends GetxController
imageStatus = false;
}
// 页面来源 稍后再看 收藏夹
RxString sourceType = 'normal'.obs;
List<MediaVideoItemModel> mediaList = <MediaVideoItemModel>[];
RxString watchLaterTitle = ''.obs;
@override
void onInit() {
super.onInit();
@@ -243,6 +254,17 @@ class VideoDetailController extends GetxController
videoItem['pic'] = argMap['pic'];
}
}
sourceType.value = argMap['sourceType'] ?? 'normal';
if (sourceType.value == 'watchLater') {
watchLaterTitle.value = '稍后再看';
fetchMediaList();
} else if (sourceType.value == 'fav') {
watchLaterTitle.value = argMap['favTitle'];
queryFavVideoList();
}
bool defaultShowComment =
setting.get(SettingBoxKey.defaultShowComment, defaultValue: false);
tabCtr = TabController(
@@ -269,6 +291,7 @@ class VideoDetailController extends GetxController
floating: floating,
heroTag: heroTag,
);
// CDN优化
// enableCDN = setting.get(SettingBoxKey.enableCDN, defaultValue: true);
@@ -292,6 +315,78 @@ class VideoDetailController extends GetxController
}
}
// 获取稍后再看列表
Future fetchMediaList() async {
final Map argMap = Get.arguments;
var count = argMap['count'];
var res = await UserHttp.getMediaList(
type: 2,
bizId: userInfo.mid,
ps: count,
);
if (res['status']) {
mediaList = res['data'].reversed.toList();
} else {
SmartDialog.showToast(res['msg']);
}
}
// 稍后再看面板展开
showMediaListPanel() {
if (mediaList.isNotEmpty) {
childKey.currentState?.showBottomSheet(
(context) => MediaListPanel(
mediaList: mediaList,
changeMediaList: changeMediaList,
panelTitle: watchLaterTitle.value,
bvid: bvid,
mediaId: Get.arguments['mediaId'],
hasMore: mediaList.length != Get.arguments['count'],
),
);
}
}
// 切换稍后再看
Future changeMediaList(bvid, cid, aid, cover) async {
try {
this.bvid = bvid;
oid.value = aid ?? IdUtils.bv2av(bvid);
this.cid.value = cid;
danmakuCid.value = cid;
videoItem['pic'] = cover;
queryVideoUrl();
Get.find<VideoReplyController>(tag: heroTag)
..aid = aid
..onRefresh();
Get.find<VideoIntroController>(tag: heroTag)
..lastPlayCid.value = cid
..bvid = bvid
..queryVideoIntro();
Get.find<RelatedController>(tag: heroTag)
..bvid = bvid
..onRefresh();
} catch (_) {}
}
// 获取收藏夹视频列表
Future queryFavVideoList() async {
final Map argMap = Get.arguments;
var mediaId = argMap['mediaId'];
var oid = argMap['oid'];
var res = await UserHttp.parseFavVideo(
mediaId: mediaId,
oid: oid,
bvid: bvid,
);
if (res['status']) {
mediaList = res['data'];
}
}
int? _lastPos;
double? _blockLimit;
List<Pair<SegmentType, SkipType>>? _blockSettings;

View File

@@ -121,7 +121,7 @@ class VideoIntroController extends GetxController
Get.find<VideoDetailController>(tag: heroTag);
// 获取视频简介&分p
void queryVideoIntro() async {
Future queryVideoIntro() async {
await queryVideoTags();
var result = await VideoHttp.videoIntro(bvid: bvid);
if (result['status']) {
@@ -649,7 +649,13 @@ class VideoIntroController extends GetxController
bool nextPlay() {
final List episodes = [];
bool isPages = false;
if ((videoDetail.value.pages?.length ?? 0) > 1) {
final VideoDetailController videoDetailCtr =
Get.find<VideoDetailController>(tag: heroTag);
if (videoDetailController.sourceType.value == 'watchLater' ||
videoDetailController.sourceType.value == 'fav') {
episodes.addAll(videoDetailCtr.mediaList);
} else if ((videoDetail.value.pages?.length ?? 0) > 1) {
isPages = true;
final List<Part> pages = videoDetail.value.pages!;
episodes.addAll(pages);
@@ -661,8 +667,7 @@ class VideoIntroController extends GetxController
episodes.addAll(episodesList);
}
}
final VideoDetailController videoDetailCtr =
Get.find<VideoDetailController>(tag: heroTag);
final PlayRepeat platRepeat = videoDetailCtr.plPlayerController.playRepeat;
if (episodes.isEmpty) {
@@ -676,6 +681,13 @@ class VideoIntroController extends GetxController
episodes.indexWhere((e) => e.cid == lastPlayCid.value);
int nextIndex = currentIndex + 1;
int cid = episodes[nextIndex].cid!;
while (cid == -1) {
nextIndex++;
SmartDialog.showToast('当前视频暂不支持播放,自动跳过');
cid = episodes[nextIndex].cid!;
}
// 列表循环
if (nextIndex >= episodes.length) {
if (platRepeat == PlayRepeat.listCycle) {
@@ -686,7 +698,6 @@ class VideoIntroController extends GetxController
return false;
}
}
final int cid = episodes[nextIndex].cid!;
final String rBvid = isPages ? bvid : episodes[nextIndex].bvid;
final int rAid = isPages ? IdUtils.bv2av(bvid) : episodes[nextIndex].aid!;
changeSeasonOrbangu(null, rBvid, cid, rAid, null);

View File

@@ -1286,46 +1286,102 @@ class _VideoDetailPageState extends State<VideoDetailPage>
);
Widget videoIntro([bool needRelated = true]) {
return CustomScrollView(
controller: _introController,
slivers: [
if (videoDetailController.videoType == SearchType.video) ...[
VideoIntroPanel(
heroTag: heroTag,
showAiBottomSheet: showAiBottomSheet,
showIntroDetail: showIntroDetail,
showEpisodes: showEpisodes,
),
if (needRelated) ...[
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.only(
top: StyleString.safeSpace,
Widget introPanel() => CustomScrollView(
controller: _introController,
slivers: [
if (videoDetailController.videoType == SearchType.video) ...[
VideoIntroPanel(
heroTag: heroTag,
showAiBottomSheet: showAiBottomSheet,
showIntroDetail: showIntroDetail,
showEpisodes: showEpisodes,
),
if (needRelated) ...[
SliverToBoxAdapter(
child: Padding(
padding: const EdgeInsets.only(
top: StyleString.safeSpace,
),
child: Divider(
height: 1,
indent: 12,
endIndent: 12,
color: Theme.of(context).dividerColor.withOpacity(0.06),
),
),
),
child: Divider(
height: 1,
indent: 12,
endIndent: 12,
color: Theme.of(context).dividerColor.withOpacity(0.06),
RelatedVideoPanel(heroTag: heroTag),
],
] else if (videoDetailController.videoType ==
SearchType.media_bangumi)
Obx(
() => BangumiIntroPanel(
heroTag: heroTag,
cid: videoDetailController.cid.value,
showEpisodes: showEpisodes,
showIntroDetail: showIntroDetail,
),
),
SliverToBoxAdapter(
child: SizedBox(height: MediaQuery.paddingOf(context).bottom),
)
],
);
if (videoDetailController.sourceType.value == 'watchLater' ||
videoDetailController.sourceType.value == 'fav') {
return Stack(
children: [
introPanel(),
Obx(
() => AnimatedPositioned(
duration: const Duration(milliseconds: 400),
curve: Curves.easeInOut,
left: 12,
right: 12,
bottom: MediaQuery.of(context).padding.bottom + 12,
child: Material(
color: Colors.transparent,
child: InkWell(
onTap: videoDetailController.showMediaListPanel,
borderRadius: const BorderRadius.all(Radius.circular(14)),
child: Container(
height: 54,
padding: const EdgeInsets.symmetric(horizontal: 16),
decoration: BoxDecoration(
color: Theme.of(context)
.colorScheme
.secondaryContainer
.withOpacity(0.95),
borderRadius: const BorderRadius.all(Radius.circular(14)),
),
child: Row(
children: [
const Icon(Icons.playlist_play, size: 24),
const SizedBox(width: 10),
Text(
videoDetailController.watchLaterTitle.value,
style: TextStyle(
color: Theme.of(context)
.colorScheme
.onSecondaryContainer,
fontWeight: FontWeight.bold,
letterSpacing: 0.2,
),
),
const Spacer(),
const Icon(Icons.keyboard_arrow_up_rounded, size: 26),
],
),
),
),
),
),
RelatedVideoPanel(heroTag: heroTag),
],
] else if (videoDetailController.videoType == SearchType.media_bangumi)
Obx(
() => BangumiIntroPanel(
heroTag: heroTag,
cid: videoDetailController.cid.value,
showEpisodes: showEpisodes,
showIntroDetail: showIntroDetail,
),
),
SliverToBoxAdapter(
child: SizedBox(height: MediaQuery.paddingOf(context).bottom),
)
],
);
],
);
} else {
return introPanel();
}
}
Widget get videoReplyPanel => Obx(

View File

@@ -463,9 +463,10 @@ class PlPlayerController {
dataSource, _looping, enableHA, hwdec, width, height);
// 获取视频时长 00:00
_duration.value = duration ?? _videoPlayerController!.state.duration;
_position.value = _sliderPosition.value = seekTo;
_position.value = _sliderPosition.value = _buffered.value = seekTo;
updateDurationSecond();
updatePositionSecond();
updateBufferedSecond();
updateSliderPositionSecond();
// 数据加载完成
dataStatus.status.value = DataStatus.loaded;

View File

@@ -2078,4 +2078,4 @@ packages:
version: "3.1.3"
sdks:
dart: ">=3.5.0 <4.0.0"
flutter: ">=3.24.5"
flutter: ">=3.24.5"