fix video progress

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-06-13 10:02:17 +08:00
parent f37e332de9
commit 653a789896
5 changed files with 40 additions and 56 deletions

View File

@@ -667,15 +667,8 @@ class VideoDetailController extends GetxController
return null;
}
Future<void> playerInit({
String? video,
String? audio,
Duration? seekToTime,
Duration? duration,
bool? autoplay,
Volume? volume,
}) async {
Duration? seek = seekToTime ?? defaultST ?? playedTime;
Future<void> playerInit({bool? autoplay}) async {
Duration? seek = defaultST ?? playedTime;
if (seek == null || seek == Duration.zero) {
seek = getFirstSegment();
}
@@ -688,15 +681,13 @@ class VideoDetailController extends GetxController
hasDashAudio: entry.hasDashAudio,
)
: NetworkSource(
videoSource: video ?? videoUrl!,
audioSource: audio ?? audioUrl,
videoSource: videoUrl!,
audioSource: audioUrl,
),
seekTo: seek,
duration:
duration ??
(data.timeLength == null
? null
: Duration(milliseconds: data.timeLength!)),
duration: data.timeLength == null
? null
: Duration(milliseconds: data.timeLength!),
isVertical: isVertical,
aid: aid,
bvid: bvid,
@@ -712,7 +703,7 @@ class VideoDetailController extends GetxController
},
width: firstVideo.width,
height: firstVideo.height,
volume: volume ?? this.volume,
volume: volume,
);
if (isClosed) return;
@@ -741,16 +732,13 @@ class VideoDetailController extends GetxController
return;
}
currLang.value = language;
queryVideoUrl(defaultST: playedTime);
queryVideoUrl(fromReset: true);
}
Volume? volume;
// 视频链接
Future<void> queryVideoUrl({
Duration? defaultST,
bool fromReset = false,
}) async {
Future<void> queryVideoUrl({bool fromReset = false}) async {
if (isFileSource) {
return _initPlayerIfNeeded();
}
@@ -790,11 +778,13 @@ class VideoDetailController extends GetxController
volume = data.volume;
final progress = args.remove('progress');
if (progress != null) {
this.defaultST = Duration(milliseconds: progress);
} else if (defaultST == null && data.lastPlayTime != null) {
this.defaultST = Duration(milliseconds: data.lastPlayTime!);
if (!fromReset) {
final progress = args.remove('progress');
if (progress != null) {
defaultST = Duration(milliseconds: progress);
} else {
defaultST = Duration(milliseconds: data.lastPlayTime);
}
}
if (!isUgc && !fromReset && plPlayerController.enablePgcSkip) {

View File

@@ -72,11 +72,7 @@ class VideoDetailPageV extends StatefulWidget {
}
class _VideoDetailPageVState extends State<VideoDetailPageV>
with
TickerProviderStateMixin,
RouteAware,
RouteAwareMixin,
WidgetsBindingObserver {
with RouteAware, RouteAwareMixin, WidgetsBindingObserver {
final heroTag = Get.arguments['heroTag'];
late final VideoDetailController videoDetailController;
@@ -1071,7 +1067,7 @@ class _VideoDetailPageVState extends State<VideoDetailPageV>
if (videoDetailController.tabCtr.length != tabs.length) {
videoDetailController.tabCtr.dispose();
videoDetailController.tabCtr = TabController(
vsync: this,
vsync: videoDetailController,
length: tabs.length,
initialIndex: tabs.isEmpty
? 0

View File

@@ -445,10 +445,7 @@ class HeaderControlState extends State<HeaderControl>
dense: true,
onTap: () {
Get.back();
videoDetailCtr.queryVideoUrl(
defaultST: videoDetailCtr.playedTime,
fromReset: true,
);
videoDetailCtr.queryVideoUrl(fromReset: true);
},
leading: const Icon(Icons.refresh_outlined, size: 20),
title: const Text('重载视频', style: titleStyle),
@@ -493,10 +490,7 @@ class HeaderControlState extends State<HeaderControl>
VideoUtils.cdnService = result;
setting.put(SettingBoxKey.CDNService, result.name);
SmartDialog.showToast('已设置为 ${result.desc},正在重载视频');
videoDetailCtr.queryVideoUrl(
defaultST: videoDetailCtr.playedTime,
fromReset: true,
);
videoDetailCtr.queryVideoUrl(fromReset: true);
}
},
),