Questions tagged [avaudiosession]

This class provides an Objective-C alternative to many features from the C-based Audio Session Services.

AVAudioSession classs reference

1047 questions
76
votes
1 answer

iOS 13 - WkWebView: audio stops when in background

I've an app that uses WkWebView to play audio from Soundcloud, on iOS 13 Beta 6 the audio stops when the app is not in foreground, even when Audio is on in Background Modes. When starting the playback this assertion is thrown: Error acquiring…
66
votes
8 answers

Are headphones plugged in? iOS7

Developing an app for an iPhone with audio files that need to be listened too through headphones. How do I check if headphones aren't plugged in so I can tell the user to plug in headphones. I have the following code from another thread but the…
4GetFullOf
  • 1,738
  • 4
  • 22
  • 47
58
votes
9 answers

AVAudioSession setCategory Swift 4.2 iOS 12 - Play Sound on Silent

To play sound even on Silent mode I use to use below method. But how it's not working. // Works on Swift 3 do { try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback) } catch { print(error) } How to get it work in…
Nitesh
  • 1,564
  • 2
  • 26
  • 53
55
votes
8 answers

How to programmatically sense the iPhone mute switch?

I can't seem to find in the SDK how to programatically sense the mute button/switch on the iPhone. When my app plays background music, it responds properly to the volume button without me having any code to follow that but, when I use the mute…
Olie
  • 24,597
  • 18
  • 99
  • 131
42
votes
5 answers

iOS8 AVAudioSession setActive error

I'm testing my app in XCode 6 and find an issue with AVAudioSession in iOS8. When I call [[AVAudioSession sharedInstance] setActive:NO error:nil]; I get the following error message: AVAudioSession.mm:623: -[AVAudioSession…
xialin
  • 7,686
  • 9
  • 35
  • 66
40
votes
8 answers

iOS check if application has access to microphone

With the introduction of iOS 7, applications have to request microphone access when they want to record audio. How do I check if the application has access to the microphone? In the iOS 8 SDK I can use the AVAudioSessionRecordPermission enum, but…
lukas
  • 2,300
  • 6
  • 28
  • 41
37
votes
4 answers

How Do I Route Audio to Speaker without using AudioSessionSetProperty?

As AudioSessionSetProperty may become deprecated, I'm trying to find an code example of how to route audio to the speaker using other means. Previously I did the following: -(void)setSpeakerEnabled { debugLog(@"%s",__FUNCTION__); UInt32…
Jim Hankins
  • 1,055
  • 1
  • 11
  • 27
34
votes
4 answers

AVAudioSessionCategoryPlayAndRecord with Airplay

My app uses the microphone and outputs audio, so I am setting my Audio Session to the Play and Record Category, but this seems to disable Airplay. If I set the category to Play, Airplay works fine with my output (but obviously the input doesn't…
thf_dave
  • 383
  • 3
  • 7
33
votes
7 answers

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

I've tried using these methods in an attempt to detect that the Ring/Silent switch is active or not: How to programmatically sense the iPhone mute switch? AVAudioSession category not working as documentation dictates But on my iPhone 4, the "state"…
taber
  • 3,166
  • 4
  • 46
  • 72
29
votes
4 answers

List available output audio target AVAudioSession

I need to list the audio outputs available to an iOS application. My question is similar to this one: How to list available audio output route on iOS i tried this code: NSError *setCategoryError = nil; BOOL success = [[AVAudioSession sharedInstance]…
lucianoenrico
  • 1,486
  • 1
  • 13
  • 21
27
votes
2 answers

Change lock screen background audio controls text?

I have an iOS app that streams background audio using AVAudioSession. It is working correctly, but I am curious, is there any way to change the text on the lock screen audio controls? Right now it simply displays the name of my app, but I would like…
Keller
  • 17,051
  • 8
  • 55
  • 72
27
votes
2 answers

Detecting active AVAudioSessions on iOS device

I'm trying to figure out if this is possible - my app activates an audio session that is initialized as: [[[AVAudioSession alloc] init] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers…
Stavash
  • 14,244
  • 5
  • 52
  • 80
26
votes
2 answers

Adding AVCaptureDeviceInput to CaptureSession resets/refocuses video

A video recording app. I want it to work without stopping/pausing background music (when user listens to Apple Music for instance). This I can do nicely with setting category to mixWithOthers on AVAudioSession singleton. After setting the category I…
Tanel Teemusk
  • 707
  • 8
  • 17
23
votes
7 answers

Low recording volume in combination with AVAudioSessionCategoryPlayAndRecord

When I set: [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayAndRecord error:NULL]; …recording and playing works fine, just the playback volume is around 60% lower than when I would just play the same sound without…
christian Muller
  • 541
  • 1
  • 5
  • 7
23
votes
2 answers

AVAudioSessionManager availableInputs "Unknown selected data source for port iPhone Microphone"

I've noticed this error in my console log for a while. Though it does not affect the execution of my application, I find it really annoying. Thus, I started to trace where this error came from. It turns out when I call availableInputs NSArray…
xialin
  • 7,686
  • 9
  • 35
  • 66
1
2 3
69 70