bluefireteam / audioplayers

A Flutter package to play multiple audio files simultaneously (Android/iOS/web/Linux/Windows/macOS)
https://pub.dartlang.org/packages/audioplayers
MIT License
2.01k stars 845 forks source link

Audio Resumes #1824

Open Copperbolt25 opened 3 months ago

Copperbolt25 commented 3 months ago

Checklist

Current bug behaviour

From Version 5.0.0> i have an audio file which plays whenever an order is landed on the app. I pause the audio when the user accepts the order. Now the issue is, the audio stops however if I go back and open instagram, play any reel with an audio, the sound previously paused starts again.

Expected behaviour

It should not unpause the sound

Steps to reproduce

  1. Execute flutter run on the code sample
  2. ...
  3. ...

run the function that starts the sound, then use anther function to pause the sound.

and then go to instagram, play any reel with sound, close it and then the sound is resumed from the app again.

Code sample

void playNewOrderSound(int timeInSeconds) async { registeredLogService.info(text: "playing new order sound"); await newOrderAudioPlayer.pause().onError( (error, stackTrace) => registeredLogService.error(error: error)); await newOrderAudioPlayer.resume().onError( (error, stackTrace) => registeredLogService.error(error: error)); _vibrationTimer?.cancel(); _stopAudioBackupTimer?.cancel(); isNewOrderPlaying = true; _vibrationTimer = Timer.periodic( const Duration(milliseconds: 1000), (timer) { Vibration.vibrate(duration: 450); }, ); _stopAudioBackupTimer = Timer( Duration( seconds: timeInSeconds, ), () => stopNewOrderSound(), ); }

void stopNewOrderSound() { registeredLogService.info(text: "stopping new order sound"); isNewOrderPlaying = false; _stopAudioBackupTimer?.cancel(); newOrderAudioPlayer.pause(); _vibrationTimer?.cancel(); }

Affected platforms

Android

Platform details

No response

AudioPlayers Version

5.0.0,6.0.0

Build mode

release

Audio Files/URLs/Sources

No response

Screenshots

No response

Logs

my relevant logs
Full Logs ``` my full logs or a link to a gist ``` Flutter doctor: ``` Output of: flutter doctor -v ```

Related issues / more information

No response

Working on PR

no way

Henriquek47 commented 2 months ago

any updated?