Comments (13)
Thanks for testing! This is now published in 0.0.9.
from audio_session.
Hi snaeji, I think that you have likely dealt with some of the issues I'm facing trying to get the audio session to become active again after a call--on iOS. This is likely not the most appropriate place to post this, but I'm pulling my hair our over here. I also can't find an email for you anywhere. If you can reach out to me I will thank you 1 million times! (give or take) [email protected]
from audio_session.
I really appreciate that you found this.
I will add a boolean wasSuspended
field to AVAudioSessionInterruptionNotification
so that the value gets exposed to the Dart layer, and then I can implement your workaround in Dart for the iOS version of becomingNoisyEventStream
.
from audio_session.
That sounds great!
I'm just glad that I can contribute. Our app has been using audio_service on Android for a year now and it is working great. And with the latest development I feel that it's now stable enough to take over our native iOS.
from audio_session.
I have just implemented this in the latest commit. I would be interested to know if it works for you. Even though I haven't pushed my changes to just_audio yet (which would prevent it from crashing with this new version of audio_session), I think you will still be able to confirm whether this feature works before a dispose occurs and crashes things.
I will let you know once the just_audio fix is also available.
from audio_session.
The just_audio changes are now available for testing. While the various git versions can be added to your pubspec, you'll probably also need to add a dependencyOverrides
section to force all of the transitive dependencies to also use those git versions.
from audio_session.
Great work! I'll get on it first thing Monday morning.
from audio_session.
I found a small bug but otherwise everything seems to work great! Running the newest commit from just_audio and audio_session.
The error output:
2020-10-12 12:20:38.498250+0000 Runner[915:53045] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[2]'
*** First throw call stack:
(0x19bd3e5ac 0x1afdb842c 0x19bdad4cc 0x19bdaaec4 0x19bc273b0 0x19bc21ef0 0x104c473c0 0x19bc9d764 0x19bc9d718 0x19bc9ccd4 0x19bc9c6a0 0x19cf305f4 0x1a35548c8 0x1a354e064 0x104e87b68 0x104e895f0 0x104e98890 0x19bcbb1e4 0x19bcb53b4 0x19bcb44bc 0x1b2739820 0x19e658734 0x19e65de10 0x10237d618 0x19b97be60)
libc++abi.dylib: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[2]'
terminating with uncaught exception of type NSException
I think it's just that we have to ensue that wasSuspended
is never null. So we probably have to init it as @(0)
and add a check for valueForKey like in the example below:
- (void) audioInterrupt:(NSNotification*)notification {
NSNumber *interruptionType = (NSNumber*)[notification.userInfo valueForKey:AVAudioSessionInterruptionTypeKey];
NSNumber *wasSuspended = @(0);
if (@available(iOS 10.3, *)) {
if ([notification.userInfo valueForKey:AVAudioSessionInterruptionWasSuspendedKey]) {
wasSuspended = [notification.userInfo valueForKey:AVAudioSessionInterruptionWasSuspendedKey];
}
}
NSLog(@"audioInterrupt");
switch ([interruptionType integerValue]) {
case AVAudioSessionInterruptionTypeBegan: {
[self invokeMethod:@"onInterruptionEvent" arguments:@[@(0), @(0), wasSuspended]];
break;
}
case AVAudioSessionInterruptionTypeEnded: {
if ([(NSNumber*)[notification.userInfo valueForKey:AVAudioSessionInterruptionOptionKey] intValue] == AVAudioSessionInterruptionOptionShouldResume) {
[self invokeMethod:@"onInterruptionEvent" arguments:@[@(1), @(1), wasSuspended]];
} else {
[self invokeMethod:@"onInterruptionEvent" arguments:@[@(1), @(0), wasSuspended]];
}
break;
}
default:
break;
}
}
from audio_session.
Hmm, I guess that means valueForKey
is returning nil
sometimes which was not expected. I'd prefer not to lose information, so I'd like to pass [NSNull null]
through the method channel in this case:
NSNumber *wasSuspended = nil;
if (@available(iOS 10.3, *)) {
wasSuspended = [notification.userInfo valueForKey:AVAudioSessionInterruptionWasSuspendedKey];
}
if (wasSuspended == nil) {
wasSuspended = [NSNull null];
}
I'll quickly make this change now.
And in hindsight, I would prefer to have done for AVAudioSessionInterruptionTypeKey
too, and will probably fix that at some point.
from audio_session.
I've made the above change in the latest commit, hopefully this will correctly pass through to Dart where it considers the null value.
from audio_session.
Ahh i see, i just googled it and found out that you can pass NSNull null
and not nil. Will check it out now.
from audio_session.
Ran into some Fabric issues so i was delayed a bit.. but the changes are working. Great work!
So now with the latest commits in just_audio and audio_session i haven't found any issues.
from audio_session.
It looks like I have made a mistake with the nullsafety version by not making wasSuspended
nullable.
Changing it to nullable is technically a breaking change but breaking change version bumps should be avoided as much as possible with audio_session since it will cause a wave of dependency version constraint problems for other packages.
Maybe since this breaking change is in an undocumented API and most people will be going through the public AudioSession
class which will not itself break, I might be able to get away with a minor version bump.
Would this cause issues for you?
from audio_session.
Related Issues (20)
- Stop audio when another app plays audio! HOT 1
- How to configure session to use Bluetooth headset mic on Android? HOT 6
- Can't build on android when targetting android 34 HOT 11
- Add privacy manifest for Apple HOT 6
- [iOS] Background audio not playing on iPhone 13+ HOT 3
- AVAudioSessionCategoryOptions.mixWithOthers stops background music the first time when audio is player, after continuing the music further sounds no longer stop the music HOT 1
- Call requires API level 23 (current min is 16) HOT 1
- Can not play by speaker on iOS HOT 3
- Is it possible to play audio when Do Not Disturb mode is on, but not in silent mode? HOT 1
- `AVAudioSessionCategoryOptions`'s `contains` method takes `AVAudioSessionInterruptionOptions`. Maybe it should be `AVAudioSessionCategoryOptions`? HOT 5
- Dependency causing an ANR in the Background HOT 3
- The music played by IOS17 is not output from Bluetooth earphones HOT 2
- Android detects the headset as if it is connected even if it is not HOT 1
- Trouble closing an audio session HOT 1
- Echo cancellation HOT 3
- Can't get current audio device HOT 1
- failed for task ':audio_session:compileReleaseJavaWithJavac' (target SDK 33) HOT 1
- AudioSessionConfiguration with multiple categories causes PlatformException(-50)
- Execution failed for task ':audio_session:compileDebugJavaWithJavac'
- [Question] Can audio playback be started while app is in the background in IOS? HOT 1
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 audio_session.