From 260313a8cdc6d404cf57e6b5d678605b97d24a5f Mon Sep 17 00:00:00 2001 From: GachiLord Date: Sun, 9 Jun 2024 18:23:06 +0500 Subject: [PATCH 1/4] apply sound effect only when track is loaded --- lib/logic/state.dart | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/logic/state.dart b/lib/logic/state.dart index 3a55b88..598470c 100644 --- a/lib/logic/state.dart +++ b/lib/logic/state.dart @@ -48,6 +48,7 @@ class PlayerState extends ChangeNotifier { _sequenceObserver(); _positionObserver(); _playingObserver(); + _processingObserver(); } // state for getters Duration? _latestDuration = Duration.zero; @@ -291,12 +292,22 @@ class PlayerState extends ChangeNotifier { void _sequenceObserver() async { await for (final _ in _player.currentIndexStream) { // apply effects - _soundEffect(); + // _soundEffect(); // update ui notifyListeners(); } } + /// Should be called only once + void _processingObserver() async { + await for (final state in _player.processingStateStream) { + // apply effects + if (state == ProcessingState.ready) { + _soundEffect(); + } + } + } + /// Should be called only once void _positionObserver() async { await for (final _ in _player.positionStream) { From 4a2425f93a2d05cc898299360a6c3c7c20df1dc0 Mon Sep 17 00:00:00 2001 From: GachiLord Date: Sun, 9 Jun 2024 18:27:53 +0500 Subject: [PATCH 2/4] change version --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 7d04e2c..2d23854 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 0.0.4+1 +version: 0.0.5+1 environment: sdk: '>=3.3.4 <4.0.0' From 3ff510ea96c2ae986e945604bffc4c996649fa41 Mon Sep 17 00:00:00 2001 From: GachiLord Date: Sun, 9 Jun 2024 19:57:45 +0500 Subject: [PATCH 3/4] remove unnecessary _soundEffect call --- lib/logic/state.dart | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/logic/state.dart b/lib/logic/state.dart index 598470c..d88b48c 100644 --- a/lib/logic/state.dart +++ b/lib/logic/state.dart @@ -291,8 +291,6 @@ class PlayerState extends ChangeNotifier { /// Should be called only once void _sequenceObserver() async { await for (final _ in _player.currentIndexStream) { - // apply effects - // _soundEffect(); // update ui notifyListeners(); } @@ -301,8 +299,8 @@ class PlayerState extends ChangeNotifier { /// Should be called only once void _processingObserver() async { await for (final state in _player.processingStateStream) { - // apply effects if (state == ProcessingState.ready) { + // apply effects _soundEffect(); } } @@ -318,7 +316,6 @@ class PlayerState extends ChangeNotifier { /// Should be called only once void _playingObserver() async { await for (final _ in _player.playingStream) { - _soundEffect(); notifyListeners(); } } From 4db46a96b2f7555ee0801363877bdc1b0378069a Mon Sep 17 00:00:00 2001 From: GachiLord Date: Sun, 9 Jun 2024 20:10:29 +0500 Subject: [PATCH 4/4] fix not working sound effect on windows when play/pause --- lib/logic/state.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/logic/state.dart b/lib/logic/state.dart index d88b48c..4a9237c 100644 --- a/lib/logic/state.dart +++ b/lib/logic/state.dart @@ -316,6 +316,8 @@ class PlayerState extends ChangeNotifier { /// Should be called only once void _playingObserver() async { await for (final _ in _player.playingStream) { + // apply effects + _soundEffect(); notifyListeners(); } }