From 74976ae83ace1955b231ef841d692d37dd28a7e6 Mon Sep 17 00:00:00 2001 From: pengtao Date: Tue, 14 Oct 2025 17:53:29 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E8=BF=9B=E9=A1=B5=E9=9D=A2seekTo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/kt_model/kt_short_video_bean.dart | 12 +++++++++++- lib/kt_pages/kt_short_video/logic.dart | 7 +++++++ lib/kt_pages/kt_short_video/state.dart | 1 + 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/kt_model/kt_short_video_bean.dart b/lib/kt_model/kt_short_video_bean.dart index c3a13f2..83fd3d0 100644 --- a/lib/kt_model/kt_short_video_bean.dart +++ b/lib/kt_model/kt_short_video_bean.dart @@ -359,6 +359,7 @@ class VideoInfo { num? isVip, Revolution? revolution, String? imageUrl, + String? playSeconds, }) { _id = id; _shortPlayVideoId = shortPlayVideoId; @@ -372,6 +373,7 @@ class VideoInfo { _isVip = isVip; _revolution = revolution; _imageUrl = imageUrl; + _playSeconds = playSeconds; } VideoInfo.fromJson(dynamic json) { @@ -389,6 +391,7 @@ class VideoInfo { ? Revolution.fromJson(json['revolution']) : null; _imageUrl = json['image_url']; + _playSeconds = json['play_seconds']; } num? _id; @@ -403,7 +406,7 @@ class VideoInfo { num? _isVip; Revolution? _revolution; String? _imageUrl; - + String? _playSeconds; VideoInfo copyWith({ num? id, num? shortPlayVideoId, @@ -417,6 +420,7 @@ class VideoInfo { num? isVip, Revolution? revolution, String? imageUrl, + String? playSeconds, }) => VideoInfo( id: id ?? _id, shortPlayVideoId: shortPlayVideoId ?? _shortPlayVideoId, @@ -430,6 +434,7 @@ class VideoInfo { isVip: isVip ?? _isVip, revolution: revolution ?? _revolution, imageUrl: imageUrl ?? _imageUrl, + playSeconds: playSeconds ?? _playSeconds, ); num? get id => _id; @@ -456,6 +461,8 @@ class VideoInfo { String? get imageUrl => _imageUrl; + String? get playSeconds => _playSeconds; + set id(num? value) => _id = value; set shortPlayVideoId(num? value) => _shortPlayVideoId = value; @@ -480,6 +487,8 @@ class VideoInfo { set imageUrl(String? value) => _imageUrl = value; + set playSeconds(String? value) => _playSeconds = value; + Map toJson() { final map = {}; map['id'] = _id; @@ -496,6 +505,7 @@ class VideoInfo { map['revolution'] = _revolution?.toJson(); } map['image_url'] = _imageUrl; + map['play_seconds'] = _playSeconds; return map; } } diff --git a/lib/kt_pages/kt_short_video/logic.dart b/lib/kt_pages/kt_short_video/logic.dart index b3577be..9ff9364 100644 --- a/lib/kt_pages/kt_short_video/logic.dart +++ b/lib/kt_pages/kt_short_video/logic.dart @@ -125,6 +125,8 @@ class VideoPlayLogic extends GetxController { state.videoId = state.video?.videoInfo?.shortPlayVideoId ?? 0; } state.episodeList = state.video?.episodeList ?? []; + state.videoFirstTime = + int.tryParse(state.video?.videoInfo?.playSeconds ?? '0') ?? 0; if (toPage) currentIndex = (state.video?.videoInfo?.episode ?? 1) - 1; for (var video in state.episodeList) { if (video.isLock == true) { @@ -142,6 +144,7 @@ class VideoPlayLogic extends GetxController { currentIndex, isToggle: true, isUploadHistorySeconds: false, + type: 1, ); } else { _initializeController(currentIndex); @@ -258,6 +261,9 @@ class VideoPlayLogic extends GetxController { }); } currentIndex = index; + if (type == 1) { + controllers[index]?.seekTo(Duration(milliseconds: state.videoFirstTime)); + } if (state.episodeList[index].isLock == true) { controllers[index]?.seekTo(Duration(seconds: 0)); controllers[index]?.pause(); @@ -280,6 +286,7 @@ class VideoPlayLogic extends GetxController { controllers[index]?.play(); } } + controllers[index]?.setPlaybackSpeed(state.currentSpeed); updateHomeVideo(); // print('----curIndex:$currentIndex'); diff --git a/lib/kt_pages/kt_short_video/state.dart b/lib/kt_pages/kt_short_video/state.dart index 5f47b49..da1e42a 100644 --- a/lib/kt_pages/kt_short_video/state.dart +++ b/lib/kt_pages/kt_short_video/state.dart @@ -8,6 +8,7 @@ class VideoPlayState { String imageUrl = ''; num shortPlayId = -1; num videoId = -1; + int videoFirstTime = 0; int curUnlock = 999; int? activityId; bool isFromDiscover = false;