Skip to content

Commit

Permalink
Revert "force setMediaItem"
Browse files Browse the repository at this point in the history
This reverts commit dd2c2a2.
  • Loading branch information
orz12 committed Jul 24, 2024
1 parent dd2c2a2 commit 81d7633
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/plugin/pl_player/controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ class PlPlayerController {
onPositionChanged.listen((Duration event) {
EasyThrottle.throttle(
'mediaServicePosition',
const Duration(milliseconds: 200),
const Duration(seconds: 1),
() => videoPlayerServiceHandler.onPositionChange(event));
}),
],
Expand Down
20 changes: 8 additions & 12 deletions lib/services/audio_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class VideoPlayerServiceHandler extends BaseAudioHandler with SeekHandler {
Box setting = GStorage.setting;
bool enableBackgroundPlay = true;
// PlPlayerController player = PlPlayerController.getInstance();
MediaItem? _lastMediaItem;

VideoPlayerServiceHandler() {
revalidateSetting();
Expand All @@ -53,6 +52,12 @@ class VideoPlayerServiceHandler extends BaseAudioHandler with SeekHandler {
// player.pause();
}

seekToNotification(Duration position) {
playbackState.add(playbackState.value.copyWith(
updatePosition: position,
));
}

@override
Future<void> seek(Duration position) async {
SmartDialog.showNotify(
Expand Down Expand Up @@ -108,16 +113,9 @@ class VideoPlayerServiceHandler extends BaseAudioHandler with SeekHandler {
if (!enableBackgroundPlay) return;

// if (_item.isEmpty) return;
if (_lastMediaItem == null) {
SmartDialog.showToast("当前没有播放内容");
Future.delayed(const Duration(milliseconds: 500), () {
setMediaItem(_lastMediaItem!);
setPlaybackState(status, isBuffering);
});
} else {
setMediaItem(_lastMediaItem!);
Future.delayed(const Duration(milliseconds: 500), () {
setPlaybackState(status, isBuffering);
}
});
}

onVideoDetailChange(dynamic data, int cid) {
Expand Down Expand Up @@ -163,7 +161,6 @@ class VideoPlayerServiceHandler extends BaseAudioHandler with SeekHandler {
if (mediaItem == null) return;
// print("exist: ${PlPlayerController.instanceExists()}");
if (!PlPlayerController.instanceExists()) return;
_lastMediaItem = mediaItem;
// _item.add(mediaItem);
setMediaItem(mediaItem);
}
Expand Down Expand Up @@ -204,7 +201,6 @@ class VideoPlayerServiceHandler extends BaseAudioHandler with SeekHandler {
onPositionChange(Duration position) {
if (!enableBackgroundPlay) return;

setMediaItem(_lastMediaItem!);
playbackState.add(playbackState.value.copyWith(
updatePosition: position,
));
Expand Down

0 comments on commit 81d7633

Please sign in to comment.