Comments (6)
I’m also experiencing issues with SoLoud’s interaction with audio_session, although I haven’t experienced the same issue as @lukepighetti.
It seems that the way SoLoud is handling interruptions internally could be interfering with attempts to use audio_session.
I made a quick example app that highlights the issue on iOS. The app uses one AudioSession instance with the exact same implementation for just_audio and SoLoud.
RPReplay_Final1721036954.mov
You can see from the video:
-
When an interruption occurs in SoLoud, the audio will not resume. You have to call
SoLoud.instance.init()
again and reload the asset before you can callplay()
successfully. This is not ideal, as it adds a lot of code and also means that the audio must be restarted again from the very beginning of the track after an interruption, losing the position of the audio that was being played. -
When an interruption occurs in just_audio, the session correctly loses and regains focus as you would expect, maintaining the position of the audio.
Ideally, SoLoud would leave all interruption logic to be handled in audio_session, which would allow for one centralized place for session logic and handling of more complex scenarios. I’ve been using the main branch as suggested by @alnitak, and also tried using a local fork of SoLoud, commenting out some of the interruption logic I could find like ma_device_notification_type_interruption_began
- but I haven’t been able to find a fix yet. This only appears to be a problem on iOS.
from flutter_soloud.
Hi @sbauly, thank you very much for your findings and your time.
This seems related to #86. When I tried to look at this, the only notifications I saw were the start
and stop
. These notifications are listened here if you are curious.
I'll try to look at this issue again even if I cannot try it on iOS. Do you mind sharing your "quick example"?
Thanks again.
from flutter_soloud.
Thanks for your speedy reply @alnitak!
Regarding #86 I’ve found that mixing sounds is possible by using the audio_session package and setting AVAudioSessionCategoryOptions.mixWithOthers
when you configure the audio session, I’ve been able to accomplish that successfully with SoLoud.
The problem I’ve found is pausing/resuming SoLoud when an interruption event occurs. Android allows multiple audio sessions so it isn’t causing problems there, but on iOS I suspect that some of the AVAudioSession
code in flutter_soloud is conflicting with audio_session in some way (possibly from miniaudio.h
?). Thanks for your suggestion - I tried commenting out the start
and stop
methods but haven’t managed to find success yet, other than re-initializing SoLoud after each interruption as a temporary workaround.
I have published the example app here, hopefully it can be helpful
from flutter_soloud.
Hey @lukepighetti,
I read ryanheise reply. Unfortunately, I don't have a Mac to try. What I can say is that loadAsset()
does nothing else than read using rootbundle
or give the file directly to the native if it is already cached.
In the flutter_soloud
version you are using, an Isolate
is used to perform the native call. This could be the only reason that come to my mind that could cause something out of the ordinary. The main
branch got rid of the Isolate and maybe worth to try it. It's not yet been published, so you should link this repo in your pubspec.yaml
like:
flutter_soloud:
git:
url: https://github.com/alnitak/flutter_soloud.git
# Add this if you want to try with the incoming web support.
# path: web
Also, have you tried to load the asset before calling _session.setActive(true)
?
from flutter_soloud.
you just need to set AVAudioSessionCategoryAmbient
if (![pAudioSession setCategory:AVAudioSessionCategoryAmbient withOptions:options error:nil]) {
return MA_INVALID_OPERATION; /* Failed to set session category to Ambient. */
}
if (!pConfig->coreaudio.noAudioSessionActivate) {
if (![pAudioSession setActive:true error:nil]) {
ma_log_postf(ma_context_get_log(pContext), MA_LOG_LEVEL_ERROR, "Failed to activate audio session.");
return MA_FAILED_TO_INIT_BACKEND;
}
}
from flutter_soloud.
Related Issues (20)
- use case: metronome HOT 5
- docs: Some questions about gapless looping audio. HOT 7
- feat: Allow getting the size of a source HOT 2
- feat: make filters easier to use HOT 5
- fix: Non ASCII characters in the file path HOT 4
- fix: audio speed discrepancy HOT 1
- fix: Not working when release for iOS HOT 20
- feat: loadUrl adds headers parameter HOT 1
- fix: Possible crash with EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0x1166800a0 HOT 3
- Check filters status
- fix: 'M_PI_2' undeclared identifier in window10 64bit HOT 1
- fix: Build fail on windows HOT 1
- fix: crash when loading many audio files asynchronously
- examples: add some more examples?
- VS Code: Lost connection to device. HOT 5
- fix: AudioSources seemingly become invalid after leaving standby (on Android) HOT 13
- feat: Deprecate waveforms HOT 8
- feat: set relative speed without changing the pitch HOT 3
- feat: schedule play HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter_soloud.