Detecting the iPhone’s Ring / Silent / Mute switch using AVAudioPlayer not working?

Well I found the answer thanks to someone from the Developer Forums, and you guys aren’t gonna like it! I’ve had a response from Apple on this. They’ve said they don’t and never have provided a method for detecting hardware mute switch and don’t intend to do so. ๐Ÿ™ IMO there is definitely value in … Read more

How Do I Route Audio to Speaker without using AudioSessionSetProperty?

On each release of iOS, more of the audioSession properties are migrated to AVFoundation, so you should use those in preference whenever available. Since iOS 6 kAudioSessionProperty_OverrideAudioRoute is represented in AVAudioSession by the method – (BOOL)overrideOutputAudioPort:error: Available values are AVAudioSessionPortOverrideNone and AVAudioSessionPortOverrideSpeaker Here is an example audio session configured entirely via AVFoundation: – (void)configureAVAudioSession { … Read more

iOS check if application has access to microphone

You can check the with recordPermission(), which has been available since iOS 8. Keep in mind that starting with iOS 10, you must set the NSMicrophoneUsageDescription property in your info.plist for microphone permissions and include a message for the user. This message is shown to the user at time of the request. Finally, if localizing … Read more

iOS8 AVAudioSession setActive error

I solved this problem, inserting this code in the method of AVAudioPlayerDelegate. -(void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag{ [audioPlayer stop]; [audioPlayer prepareToPlay]; } where audioPlayer is a variable declared in the header of my class. the instruction prepareToPlay should resolve your problem!

How to programmatically sense the iPhone mute switch?

Thanks, JPM. Indeed, the link you provide leads to the correct answer (eventually. ๐Ÿ˜‰ For completeness (because S.O. should be a source of QUICK answers! )… // “Ambient” makes it respect the mute switch // Must call this once to init session if (!gAudioSessionInited) { AudioSessionInterruptionListener inInterruptionListener = NULL; OSStatus error; if ((error = AudioSessionInitialize … Read more

Are headphones plugged in? iOS7

This should work, but I cannot test it right now, I’ll do in the evening. – (BOOL)isHeadsetPluggedIn { AVAudioSessionRouteDescription* route = [[AVAudioSession sharedInstance] currentRoute]; for (AVAudioSessionPortDescription* desc in [route outputs]) { if ([[desc portType] isEqualToString:AVAudioSessionPortHeadphones]) return YES; } return NO; }

iOS 13 – WkWebView: audio stops when in background

I guess you are using Capacitor. I’m running into the same issue as you and it looks like the last error about ‘no background task exists’ has something to do with Capacitor’s BackgroundTask Plugin, wether you’re using it or not (BackgroundTask.swift) It’s clear something changed between iOS 12 and iOS 13, but so far haven’t … Read more