feat:进页面seekTo

This commit is contained in:
pengtao 2025-10-14 17:53:29 +08:00
parent bcdce80889
commit 74976ae83a
3 changed files with 19 additions and 1 deletions

View File

@ -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<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = _id;
@ -496,6 +505,7 @@ class VideoInfo {
map['revolution'] = _revolution?.toJson();
}
map['image_url'] = _imageUrl;
map['play_seconds'] = _playSeconds;
return map;
}
}

View File

@ -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');

View File

@ -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;