From 00ea891784119c51123bfd1316a9f1eb37c89a70 Mon Sep 17 00:00:00 2001 From: bggRGjQaUbCoE Date: Sat, 1 Mar 2025 17:13:04 +0800 Subject: [PATCH] fix: clear audio noti Signed-off-by: bggRGjQaUbCoE --- lib/plugin/pl_player/controller.dart | 2 +- lib/services/audio_handler.dart | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index b25aab486..55aa5f256 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -1529,7 +1529,6 @@ class PlPlayerController { return; } _playerCount.value = 0; - videoPlayerServiceHandler.clear(); Utils.channel.setMethodCallHandler(null); pause(); try { @@ -1560,6 +1559,7 @@ class PlPlayerController { _videoPlayerController = null; } _instance = null; + videoPlayerServiceHandler.clear(); } catch (err) { debugPrint(err.toString()); } diff --git a/lib/services/audio_handler.dart b/lib/services/audio_handler.dart index b002ec1b8..b1b42b135 100644 --- a/lib/services/audio_handler.dart +++ b/lib/services/audio_handler.dart @@ -67,7 +67,9 @@ class VideoPlayerServiceHandler extends BaseAudioHandler with SeekHandler { } Future setPlaybackState(PlayerStatus status, bool isBuffering) async { - if (!enableBackgroundPlay || PlPlayerController.instanceExists().not) { + if (!enableBackgroundPlay || + _item.isEmpty || + PlPlayerController.instanceExists().not) { return; } @@ -192,7 +194,9 @@ class VideoPlayerServiceHandler extends BaseAudioHandler with SeekHandler { } onPositionChange(Duration position) { - if (!enableBackgroundPlay) return; + if (!enableBackgroundPlay || + _item.isEmpty || + PlPlayerController.instanceExists().not) return; playbackState.add(playbackState.value.copyWith( updatePosition: position,