feat: 修复分P视频媒体通知错乱问题
This commit is contained in:
@ -77,18 +77,31 @@ class VideoPlayerServiceHandler extends BaseAudioHandler with SeekHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onVideoDetailChange(dynamic data, int cid) {
|
onVideoDetailChange(dynamic data, int cid) {
|
||||||
|
if (data == null) return;
|
||||||
Map argMap = Get.arguments;
|
Map argMap = Get.arguments;
|
||||||
final heroTag = argMap['heroTag'];
|
final heroTag = argMap['heroTag'];
|
||||||
|
|
||||||
late MediaItem? mediaItem;
|
late MediaItem? mediaItem;
|
||||||
if (data is VideoDetailData) {
|
if (data is VideoDetailData) {
|
||||||
mediaItem = MediaItem(
|
if ((data.pages?.length ?? 0) > 0) {
|
||||||
id: heroTag,
|
final current = data.pages?.firstWhere((element) => element.cid == cid);
|
||||||
title: data.title ?? "",
|
mediaItem = MediaItem(
|
||||||
artist: data.owner?.name ?? "",
|
id: heroTag,
|
||||||
duration: Duration(seconds: data.duration ?? 0),
|
title: current?.pagePart ?? "",
|
||||||
artUri: Uri.parse(data.pic ?? ""),
|
artist: data.title ?? "",
|
||||||
);
|
album: data.title ?? "",
|
||||||
|
duration: Duration(seconds: current?.duration ?? 0),
|
||||||
|
artUri: Uri.parse(data.pic ?? ""),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
mediaItem = MediaItem(
|
||||||
|
id: heroTag,
|
||||||
|
title: data.title ?? "",
|
||||||
|
artist: data.owner?.name ?? "",
|
||||||
|
duration: Duration(seconds: data.duration ?? 0),
|
||||||
|
artUri: Uri.parse(data.pic ?? ""),
|
||||||
|
);
|
||||||
|
}
|
||||||
} else if (data is BangumiInfoModel) {
|
} else if (data is BangumiInfoModel) {
|
||||||
final current =
|
final current =
|
||||||
data.episodes?.firstWhere((element) => element.cid == cid);
|
data.episodes?.firstWhere((element) => element.cid == cid);
|
||||||
@ -110,7 +123,6 @@ class VideoPlayerServiceHandler extends BaseAudioHandler with SeekHandler {
|
|||||||
processingState: AudioProcessingState.idle,
|
processingState: AudioProcessingState.idle,
|
||||||
playing: false,
|
playing: false,
|
||||||
));
|
));
|
||||||
stop();
|
|
||||||
_item.removeLast();
|
_item.removeLast();
|
||||||
if (_item.isNotEmpty) {
|
if (_item.isNotEmpty) {
|
||||||
setMediaItem(_item.last);
|
setMediaItem(_item.last);
|
||||||
@ -118,16 +130,18 @@ class VideoPlayerServiceHandler extends BaseAudioHandler with SeekHandler {
|
|||||||
if (_item.isEmpty) {
|
if (_item.isEmpty) {
|
||||||
playbackState
|
playbackState
|
||||||
.add(playbackState.value.copyWith(updatePosition: Duration.zero));
|
.add(playbackState.value.copyWith(updatePosition: Duration.zero));
|
||||||
|
stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
|
mediaItem.add(null);
|
||||||
playbackState.add(PlaybackState(
|
playbackState.add(PlaybackState(
|
||||||
processingState: AudioProcessingState.idle,
|
processingState: AudioProcessingState.idle,
|
||||||
playing: false,
|
playing: false,
|
||||||
));
|
));
|
||||||
mediaItem.add(null);
|
|
||||||
_item.clear();
|
_item.clear();
|
||||||
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
onPositionChange(Duration position) {
|
onPositionChange(Duration position) {
|
||||||
|
Reference in New Issue
Block a user