This class provides an Objective-C alternative to many features from the C-based Audio Session Services.
Questions tagged [avaudiosession]
1047 questions
12
votes
4 answers
Performing vibration in recording app
I am trying to perform a vibration in an app similar to Snapchat, that uses both audio output and input as well as supports audio mixing from other apps, but this seems to be a harder task that I initially thought it would be. Important to know is…

Daniel Larsson
- 6,278
- 5
- 44
- 82
12
votes
2 answers
Use of beginReceivingRemoteControlEvents
I saw people use: [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; to handle remote control event when managing audio session.
My question:
Does this code only can be used in either a UIViewController class or AppDelegate…

Leem.fin
- 40,781
- 83
- 202
- 354
12
votes
1 answer
iOS - AVAudioSession Route Change Notification in background
Despite many posts on the subject (AVPlayer & AVAudioSession, Setting the AVAudioSession category in AppDelegate.m, AvAudioSession won't work in iOS7?), I could not solve this specific issue in iOS 7:
- I want to receive AVAudioSession Route Change…

user3217125
- 579
- 5
- 12
12
votes
4 answers
Lower iPod volume to play app sound (like the native SMS app)
I've made an iPhone app to be used while exercising. It plays a bell tone to indicate that you (the user) should switch from one step of your exercise routine to the next. I've designed the app so that you can listen to music on the iPod while…

Justin Gallagher
- 3,242
- 21
- 25
12
votes
3 answers
AVAudioSession Interruptions
So in my app, running on iOS 6, everything seems to work fine with audio. I use the old C API format to catch interruptions using a callback; setting up via: AudioSessionInitialize(NULL, NULL, interruptionListenerCallback, (__bridge void *)self)…

Doc
- 1,480
- 2
- 16
- 28
12
votes
2 answers
iOS AudioSessionSetActive() blocking main thread?
in my iOS app, I'm trying to implement "ducking": while my app plays a short "command-like" sound, any background music should be lowered in volume. Having finished playing the sound, the music volume should go back to its original value.
As…

Goetz Reyher
- 121
- 1
- 5
12
votes
3 answers
AVAudioSessionCategoryPlayAndRecord makes AirPlay invisible
I am encountering the following problem: AirPlay becomes not available whenever I set play-and-record category to the audio session in my application:
[[AVAudioSession sharedInstance]
setCategory: AVAudioSessionCategoryPlayAndRecord
…

Anastasia
- 3,024
- 1
- 23
- 34
12
votes
5 answers
AVAudioSessionDelegate called at endInterruption, but beginInterruption not called
I'm setting up an AVAudioSession when the app launches and setting the delegate to the appDelegate. Everything seems to be working (playback, etc) except that beginInterruption on the delegate is not being called when the phone receives a call. When…

Farski
- 1,670
- 3
- 15
- 30
11
votes
3 answers
iOS - AVAudioPlayer doesn't continue to next song while in background
So I have an app that plays a bunch of songs while the user can flip through a comic book. I use AVAudioPlayer and I have it set up to play the songs in a set order. So when one song finishes, the next one will play. This works flawlessly when…

kernelpanic
- 530
- 2
- 8
- 26
11
votes
2 answers
AVPlayer audioSessionGotInterrupted notification when waking up from background
I use AVAudioPlayer to play audio. I have background audio enabled and the audio sessions are configured correctly.
I implemented the audioSessionGotInterrupted method to be informed if the audio session gets interrupted. This is my current…

funkenstrahlen
- 3,032
- 2
- 28
- 40
11
votes
4 answers
How to change an iOS device volume programmatically?
Is there a way to change the device volume programmatically? maybe using audio session?

DrCachetes
- 954
- 1
- 9
- 30
11
votes
3 answers
AVAudioSession Swift
I am trying to write a swift iOS app that will record the users voice. I have wrote the following code in swift however it fails to request mic permissions from the user. It prints granted yet it never records audio and in the settings pane under…

BDGapps
- 3,318
- 10
- 56
- 75
11
votes
3 answers
Playing music at back ground: AVAudioSessionInterruptionNotification not fired
My app is playing in background well. Pause and play also works well even my app is background using the methods registered for AVAudioSessionInterruptionNotification.
The problem arrives steps for the scenario:
Launch my app -> goes background…

jailani
- 2,260
- 2
- 21
- 45
10
votes
0 answers
required condition is false: format.sampleRate == hwFormat.sampleRate in my iPhone 11 Pro
I am using AVAudioSession and AVAudioInputNode to record voice in iOS.
To initialise it I was using the following settings, which was working fine:
[AVFormatIDKey: kAudioFormatLinearPCM, AVLinearPCMBitDepthKey: 16, AVLinearPCMIsFloatKey: true,…

Joan Cardona
- 3,463
- 2
- 25
- 43
10
votes
0 answers
AVAudioSession route change iOS 12
I am having following after upgrading to iOS 12 & XCode 10:
2018-09-20 11:58:09.622656+0400 MyApp-Swift[1027:137400] [avas] AVAudioSessionPortImpl.mm:56:ValidateRequiredFields: Unknown selected data source for Port Speaker (type: Speaker)
Any idea…

Deepak Sharma
- 5,577
- 7
- 55
- 131