[check] Multiple SoundPlayers
See original GitHub issueFlutter Sound Version :
-
Released or Beta version ? Released
-
Version number ? 6.4.8
-
FULL or LITE flavor ? Both (recently switched to lite)
-
Result of the command “flutter pub deps | grep flutter_sound”
|-- flutter_sound_lite 6.4.8+2
| |-- flutter_sound_platform_interface 6.4.8+2
| |-- flutter_sound_web 6.4.8+2
| | |-- flutter_sound_platform_interface...
Severity
-
Crash ? No
-
Result is not what expected ? Yes
-
Cannot build my App ? No
-
Minor issue ? I’d rate it medium or minor.
Platforms you faced the error
-
iOS ? Yes
-
Android ? Yes
-
Both ? Yes
-
Emulator ? (not tested)
-
Real device ? Yes
Logs
When starting the second song:
flutter: FS:---> openAudioSession
flutter: FS:---> channelMethodCallHandler : openAudioSessionCompleted
flutter: FS:<--- channelMethodCallHandler : openAudioSessionCompleted
flutter: FS:<--- openAudioSession
flutter: FS:---> setSubscriptionDuration
flutter: FS:<---- setSubscriptionDuration
flutter: FS:---> startPlayer
flutter: FS:---> stop
flutter: FS:<--- stop
flutter: FS:---> _convert
flutter: FS:---> needToConvert
flutter: FS:<--- needToConvert
flutter: FS:<--- _convert
flutter: FS:---> channelMethodCallHandler : startPlayerCompleted
flutter: FS:<--- channelMethodCallHandler : startPlayerCompleted
flutter: FS:<--- startPlayer
flutter: FS:---> openAudioSession
flutter: FS:---> channelMethodCallHandler : openAudioSessionCompleted
flutter: FS:<--- channelMethodCallHandler : openAudioSessionCompleted
flutter: FS:<--- openAudioSession
flutter: FS:---> setSubscriptionDuration
flutter: FS:<---- setSubscriptionDuration
flutter: FS:---> startPlayer
flutter: FS:---> stop
flutter: FS:<--- stop
flutter: FS:---> _convert
flutter: FS:---> needToConvert
flutter: FS:<--- needToConvert
flutter: FS:<--- _convert
flutter: FS:---> channelMethodCallHandler : startPlayerCompleted
flutter: FS:<--- channelMethodCallHandler : startPlayerCompleted
flutter: FS:<--- startPlayer
flutter: FS:---> pausePlayer
flutter: FS:<--- pausePlayer
flutter: FS:---> pausePlayer
flutter: FS:<--- pausePlayer
Describe the bug
Using 2 SoundPlayers in the same application causes one of them to misbehave, when they are playing simultaneously. The first player starts to play the song of the second player and the durations of the song seems to not match anymore.
To Reproduce Steps to reproduce the behavior:
- Create an application with 2 SoundPlayers controlled by a button, each playing a different song.
- Start playing the first song.
- Before the first song is finished, start playing the second song.
- You should notice that the first player seems to start the second song with a bit of a delay, so both players are now playing the second song.
Expected behavior
I’m not sure, what the best behaviour is. Not all platforms support multiple sound outputs at the same time. I’d probably prefer to stop the first player implicitly in this case. Playing both songs at the same time is fine too.
Additional context**
flutter_sound already keeps track of the different audio sessions, so it should be somewhat easy to stop them automatically, although an event would need to be emitted, that the song is now paused. From my testing I don’t see any mixup there happening too, so the issues seem to be in TauEngine or lower at the OS level. This could also be handled at the application level, but since flutter_sound already keeps track of it, that sounds more appropriate. Tell me your thoughts and if it is not something, that can be done soon, I may look into how to implement that, but I’m not really well versed in flutter sound stuff yet. This may also actually be a feature request instead of a bug report, so feel free to reassign.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top GitHub Comments
Hi @deepbluev7 . Thank you for your very detailed PR (Problem Report). Yes, Flutter Sound was supposed to be able to play several sound at the same time. This has not been tested very well, and I was thinking to create a new simple example doing that.
I am going to study your PR more carefully when I will have finished working on the fucking documentation (in a few days).
Thank you again. It would be really great if everybody fill PRs like your. Detailed, clear and positive.
Hi @deepbluev7 ,
I wrote a simple example doing three playbacks at the same time here.
I did not see any problems. Could you check on your side that everything OK ?