-
-
Notifications
You must be signed in to change notification settings - Fork 47
feat: trying to disable audio context #257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ScreenRecording_06-25-2025.16-58-14_1.MP4ScreenRecording_06-25-2025.16-59-36_1.MP4Hey @alnitak thanks for the clarification. But in both cases the audio does not regain after interruption. |
I have pushed a commit that may solve this. I think you will need to On iOS, when So, you can now try again to: Please, can you also try to check the duck event?
Thanks! |
ScreenRecording_06-25-2025.17-58-04_1.1.mp4I've run Logs:
I'll try the duck event soon. |
I'm really sorry I didn't get the chance to try it out myself. Anyway, looking at your recording, I think the audio engine has not been disposed, hence it doesn't need to be initialized again as before this PR. When you press the I am not sure, and I am not very familiar with audio_session and how it works, but maybe now we have to look for something on the Flutter side, like the app life cycle, where, for example, try putting an Maybe @adventureisyou or @sbauly can give us some insights? |
@alnitak I'm not familiar with audio systems at all but as I understand, the problem is The problem on iOS is that It may work if there is some way we could check, every time on For my use case the PR's current state works great because I'm using SoLoud for sound effects which mix with other audios. It's great that I'm given explicit control over AVAudioSession using await session.configure(
const AudioSessionConfiguration(
avAudioSessionCategory: AVAudioSessionCategory.playback,
avAudioSessionCategoryOptions:
AVAudioSessionCategoryOptions.mixWithOthers,
),
); Please feel free to let me know if you need more tests. |
@MinseokKang003 I have merged your PR and updated the example a bit. Could you please confirm that running the example and doing what is described in the first post under the "Testing by running the example" is working for you? Thank you very much! |
interruption-1.MP4interruption-2.MP4interruption-3.mp4To test audio interruption in iOS, we need to set
Everything seems to work fine here. |
@MinseokKang003 this is great!! I am very grateful, thank you! I think that, for now, we are ready to go. All the audio context seems to be managed only by |
Yup no problems so far on my side. Feel free to merge! It's great to contribute. |
+1 nice job |
were you able to get this to work on iOS side? I'm not able to get playback still when implementing |
I just tried to |
Hi. Sorry for the silence on my part, it's been a busy week! Thanks for all your work on this. I've just tried using this branch for our app, and it seems to accomplish two things:
The first solves my issue of spotify being interrupted on startup. I'm now able to set my own audio category to ambient and it doesn't get overridden by miniaudio. This means YouTube/Spotify don't get interrupted when opening the app. INCORRECT SEE NEXT COMMENT
Finally, I think I need to apologise for conflating my startup focus issue with the original reports of audio session interruptions causing problems. My experiece is that even without this change, I'm unable to repro any of the symptoms in the original ticket. Both
|
Gahh - maybe I'm talking rubbish. I tried this branch again without manual audio session management and it seems to work fine - though I don't understand how. |
OH - the |
Your comment appeared just 2 seconds before I wanted to hit the "Merge" button 😄 ! Anyway, no problem at all, you are welcome to tell me your point of view and suggestions!! Agreed with the fact that there are a lot of combinations to test and cannot be automated (I think), and I can't tell how many times I got confused too :) If you need some more time to test your use cases, please tell me. I have no problem waiting to merge. I'd prefer to be sure that all is working fine. If you are just fine with this PR, I can merge and publish on pub.dev now. Take all the time! |
Hah, sorry. I was writing it while testing and then saw you merge master back in and thought I'd post it quickly to stop you merging. Then realised I was wrong! I'm very happy, let's merge! Thanks again. |
Description
This PR disables the audio context and device routing of miniaudio, allowing developers to use a third-party plugin such as audio_session instead.
A new example has been added:
example/lib/audio_context/audio_context.dart
.This has been tested and is working on Android. For example, after running the app and starting a YouTube video, the music is paused as expected. When an event arrives:
AudioInterruptionType.unknown
event withevent.begin=true
, but no correspondingevent.begin=false
.AudioInterruptionType.duck
event withevent.begin=true
.The purpose of the
unpause
button in the example:The YT app (and I think other music apps I tested on Android) takes ownership of the audio context when playing. The
audio_session
plugin, in this case, grabs theAudioInterruptionType.unknown
which just pause the playback here in the example, but theevent.begin=false
of this unknown event is not fired. TL;DR the sound in the example remains paused (in the audio_session example, the author does nothing in that case).This means that if you press the
unpause
button and you hear the sound, it is working!! Because, without the PR, in that case, you had to call againsoloud.ini()
.On Android, I wasn't able to trigger
AudioInterruptionType.pause
. YouTube Music, YouTube Video, and other music apps seem to only triggerAudioInterruptionType.unknown
.Unfortunately, I don’t have access to a real iOS device to test this. If anyone is able to try it out on iOS, I’d greatly appreciate your feedback.
For those who wish to try this out, the core part to look at is in miniaudio_init.
Fixes #104, fixes #245, fixes #249
For anyone who would like to help test in their app, please use the reference below in your
pubspec.yaml
:Testing by running the example, you could try:
unknown
stateunpause
button, the example sound must play againor
Type of Change