diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index dfa580ab6..b4b37cea8 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -277,8 +277,7 @@ class PlPlayerController { danmakuDurationVal = localCache.get(LocalCacheKey.danmakuDuration, defaultValue: 4.0); // 描边粗细 - strokeWidth = - localCache.get(LocalCacheKey.strokeWidth, defaultValue: 1.5); + strokeWidth = localCache.get(LocalCacheKey.strokeWidth, defaultValue: 1.5); playRepeat = PlayRepeat.values.toList().firstWhere( (e) => e.value == @@ -535,8 +534,10 @@ class PlPlayerController { if (event) { playerStatus.status.value = PlayerStatus.playing; } else { - // playerStatus.status.value = PlayerStatus.paused; + playerStatus.status.value = PlayerStatus.paused; } + videoPlayerServiceHandler.onStatusChange( + playerStatus.status.value, isBuffering.value); /// 触发回调事件 for (var element in _statusListeners) { diff --git a/lib/services/audio_handler.dart b/lib/services/audio_handler.dart index 0b37d4192..bf98298b8 100644 --- a/lib/services/audio_handler.dart +++ b/lib/services/audio_handler.dart @@ -26,6 +26,7 @@ class VideoPlayerServiceHandler extends BaseAudioHandler with SeekHandler { static final List _item = []; Box setting = GStrorage.setting; bool enableBackgroundPlay = false; + PlPlayerController player = PlPlayerController.getInstance(); VideoPlayerServiceHandler() { revalidateSetting(); @@ -38,12 +39,12 @@ class VideoPlayerServiceHandler extends BaseAudioHandler with SeekHandler { @override Future play() async { - PlPlayerController.getInstance().play(); + player.play(); } @override Future pause() async { - PlPlayerController.getInstance().pause(); + player.pause(); } @override @@ -51,7 +52,7 @@ class VideoPlayerServiceHandler extends BaseAudioHandler with SeekHandler { playbackState.add(playbackState.value.copyWith( updatePosition: position, )); - await PlPlayerController.getInstance().seekTo(position); + await player.seekTo(position); } Future setMediaItem(MediaItem newMediaItem) async { diff --git a/lib/services/audio_session.dart b/lib/services/audio_session.dart index 57c42e053..ea83a30aa 100644 --- a/lib/services/audio_session.dart +++ b/lib/services/audio_session.dart @@ -20,7 +20,7 @@ class AudioSessionHandler { session.interruptionEventStream.listen((event) { final player = PlPlayerController.getInstance(); if (event.begin) { - if (player.playerStatus != PlayerStatus.playing) return; + if (!player.playerStatus.playing) return; switch (event.type) { case AudioInterruptionType.duck: player.setVolume(player.volume.value * 0.5); @@ -52,7 +52,7 @@ class AudioSessionHandler { // 耳机拔出暂停 session.becomingNoisyEventStream.listen((_) { final player = PlPlayerController.getInstance(); - if (player.playerStatus == PlayerStatus.playing) { + if (player.playerStatus.playing) { player.pause(); } });