Skip to content

Commit

Permalink
Merge pull request #13 from GachiLord/fix/sound-effect-delay-on-android
Browse files Browse the repository at this point in the history
Fix/sound effect delay on android
  • Loading branch information
GachiLord authored Jun 9, 2024
2 parents 46bdb49 + 4db46a9 commit 3bc7de4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions lib/logic/state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class PlayerState extends ChangeNotifier {
_sequenceObserver();
_positionObserver();
_playingObserver();
_processingObserver();
}
// state for getters
Duration? _latestDuration = Duration.zero;
Expand Down Expand Up @@ -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) {
Expand All @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 3bc7de4

Please sign in to comment.