diff --git a/lib/logic/state.dart b/lib/logic/state.dart index 3a55b88..4a9237c 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; @@ -290,13 +291,21 @@ class PlayerState extends ChangeNotifier { /// Should be called only once void _sequenceObserver() async { await for (final _ in _player.currentIndexStream) { - // apply effects - _soundEffect(); // update ui notifyListeners(); } } + /// Should be called only once + void _processingObserver() async { + await for (final state in _player.processingStateStream) { + if (state == ProcessingState.ready) { + // apply effects + _soundEffect(); + } + } + } + /// Should be called only once void _positionObserver() async { await for (final _ in _player.positionStream) { @@ -307,6 +316,7 @@ class PlayerState extends ChangeNotifier { /// Should be called only once void _playingObserver() async { await for (final _ in _player.playingStream) { + // apply effects _soundEffect(); notifyListeners(); } 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'