avaudiosession

AVAudioSession - How to switch between speaker and headphones output

陌路散爱 提交于 2020-06-27 09:05:10
问题 I'm trying to mimic behaviour as in Phone app during calling. You can easily switch output sources from/to speaker or headphones. I know I can force speaker as an output when headphones are connected by calling: try! audioSession.setCategory(AVAudioSessionCategoryPlayAndRecord) try! audioSession.overrideOutputAudioPort(.speaker) However, when I do that, I don't see any way to detect if headphones are still connected to the device. I initially thought outputDataSources on AVAudioSession would

How to use the stereo (2 channel) built in microphone in iPhone XS, inside AVAudioSession?

自古美人都是妖i 提交于 2020-05-15 08:41:53
问题 I'm trying to get both channels from the supposedly stereo rear microphone out of the iPhone XS but can only ever see a single channel at various points in the AVAudioSession and AVAudioSessionPortDescription's associated with the rear camera. I have tried using AVAudioSession APIs like setPreferredInputNumberOfChannels do { try session.setPreferredInputNumberOfChannels(2) } catch let error { debugPrint("\(error)") } But get an error: Error Domain=NSOSStatusErrorDomain Code=-50 Has anyone had

iOS 13 - WkWebView: audio stops when in background

倖福魔咒の 提交于 2020-05-09 17:57:46
问题 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 assertions is thrown: Error acquiring assertion: <NSError: 0x282cf67c0; domain: RBSAssertionErrorDomain; code: 2; reason: "Required client entitlement is missing"> { userInfo = { RBSAssertionAttribute = <RBSLegacyAttribute: 0x1592432e0; requestedReason: MediaPlayback; reason: MediaPlayback

AVAudioSession setCategory error

半城伤御伤魂 提交于 2020-01-24 06:08:31
问题 Trying this: [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&error]; if (error) { NSLog(@"Error setting category: %@", [error description]); } Getting the error back "Error setting category: UIView" but am not sure how to go about fixing this. Not entirely sure what it's telling me. Help please! EDIT Audio Playback: NSURL *audioFileURL = [[NSBundle mainBundle] URLForResource:@"DemoSong" withExtension:@"m4a"]; NSError *error; self.audioPlayer = [

AVAudioSession setCategory error

天涯浪子 提交于 2020-01-24 06:07:05
问题 Trying this: [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&error]; if (error) { NSLog(@"Error setting category: %@", [error description]); } Getting the error back "Error setting category: UIView" but am not sure how to go about fixing this. Not entirely sure what it's telling me. Help please! EDIT Audio Playback: NSURL *audioFileURL = [[NSBundle mainBundle] URLForResource:@"DemoSong" withExtension:@"m4a"]; NSError *error; self.audioPlayer = [

Audio won't play after app interrupted by phone call iOS

邮差的信 提交于 2020-01-22 17:10:48
问题 I have a problem in my SpriteKit game where audio using playSoundFileNamed(_ soundFile:, waitForCompletion:) will not play after the app is interrupted by a phone call. (I also use SKAudioNodes in my app which aren't affected but I really really really want to be able to use the SKAction playSoundFileNamed as well.) Here's the gameScene.swift file from a stripped down SpriteKit game template which reproduces the problem. You just need to add an audio file to the project and call it "note" I

Audio won't play after app interrupted by phone call iOS

拥有回忆 提交于 2020-01-22 17:10:31
问题 I have a problem in my SpriteKit game where audio using playSoundFileNamed(_ soundFile:, waitForCompletion:) will not play after the app is interrupted by a phone call. (I also use SKAudioNodes in my app which aren't affected but I really really really want to be able to use the SKAction playSoundFileNamed as well.) Here's the gameScene.swift file from a stripped down SpriteKit game template which reproduces the problem. You just need to add an audio file to the project and call it "note" I

Switching avaudiosession categories then retaking control of remote control center controls

假如想象 提交于 2020-01-21 15:13:10
问题 This is my first post asking a question as i never usually need help but i can't figure out if this is even possible. What i need is to switch between these two categories of avaudiosession and when the switch is made from mixing allowed to no mixing for the app take back control of the remote controls in the control center. [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil] and [[AVAudioSession

Switching avaudiosession categories then retaking control of remote control center controls

霸气de小男生 提交于 2020-01-21 15:10:22
问题 This is my first post asking a question as i never usually need help but i can't figure out if this is even possible. What i need is to switch between these two categories of avaudiosession and when the switch is made from mixing allowed to no mixing for the app take back control of the remote controls in the control center. [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil] and [[AVAudioSession

Switching avaudiosession categories then retaking control of remote control center controls

青春壹個敷衍的年華 提交于 2020-01-21 15:09:08
问题 This is my first post asking a question as i never usually need help but i can't figure out if this is even possible. What i need is to switch between these two categories of avaudiosession and when the switch is made from mixing allowed to no mixing for the app take back control of the remote controls in the control center. [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil] and [[AVAudioSession