avaudiosession

iOS AudioSessionSetActive() blocking main thread?

こ雲淡風輕ζ 提交于 2019-11-30 03:12:15
问题 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 implemented, ducking basically works as expected. However, when I call AudioSessionSetActive(NO) in audioPlayerDidFinishPlaying: in order to end ducking, there is a small pause in any UI updates that occur at this point of time. This involves custom

how to show seek track duration on control center

*爱你&永不变心* 提交于 2019-11-29 23:21:40
How do i pass the song info such as song name and track duration to control center. Player plays music fine and the play and pause control works fine though. Playing with apple's music app Playing with my app with the code below, how to pass song information in order to display it ? //AppDelegate -(void)setupAudio { // Set AVAudioSession NSError *sessionError = nil; [[AVAudioSession sharedInstance] setDelegate:self]; [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&sessionError]; // Change the default output audio route UInt32 doChangeDefaultRoute = 1;

AVAudioSession setCategory Swift 4.2 iOS 12 - Play Sound on Silent

流过昼夜 提交于 2019-11-29 22:07:01
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 4.2 / iOS 12? In newer version we need to set mode and options. try AVAudioSession.sharedInstance().setCategory( <#T##category:AVAudioSession.Category##AVAudioSession.Category#>, mode: <#T##AVAudioSession.Mode#>, options: <#T##AVAudioSession.CategoryOptions#>)` Her der Töne's comment shows you the new syntax, but you also need to activate the audio session

AVAudioSession's OutputVolume never changes

烈酒焚心 提交于 2019-11-29 13:53:42
There are plenty of questions and answers on SO that say [AVAudioSession sharedInstance].outputVolume is the only way to detect a device's volume. But it doesn't seem to work quite right. outputVolume never changes, though it is correct when it is first set (at application launch). Am I doing it wrong? I don't know what else to do besides reading the value of outputVolume . My instincts would tell me this was a bug, if it wasn't for the fact that other people seem to be doing it just fine. I also tested it on iOS 7 and 8, so it's not an iOS 8 bug. I reproduced the same thing in a small test

Recording from Built-In Mic when Playing through Bluetooth in iOS

北城余情 提交于 2019-11-29 11:41:11
Is it possible to receive audio input from iPhone's built-in microphone, and play that audio through a Bluetooth headset, at the same time? My goal is to always use the built-in microphone as the input device, even if the output device is a headset, because the built-in microphone is more convenient in my use cases. I know how to achieve my goal when the output device is a wired headset, like the one that comes bundled with an iPhone. I simply plug the wired headset in, and call the following method: - (void)selectBuiltInMicrophone { AVAudioSession *session = [AVAudioSession sharedInstance];

Unable to receive remoteControlReceivedWithEvent - objective c - ios

南楼画角 提交于 2019-11-29 11:00:35
I successfully enabled my app to be able to play audio and video in background after the screen is locked. However, for better user experience I want to show play and pause controls of the running media on the locked screen. After following couple of blogs online, added the following code: @interface MyControllerClass () <UIGestureRecognizerDelegate, UIApplicationDelegate> - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [[UIApplication sharedApplication] beginReceivingRemoteControlEvents]; [self becomeFirstResponder]; AVURLAsset *avAsset = [AVURLAsset URLAssetWithURL:url

AVAudioSession Swift

蹲街弑〆低调 提交于 2019-11-29 10:10:37
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 privacy it does not list the app. How do I request recording permissions in swift? var session: AVAudioSession = AVAudioSession.sharedInstance() session.requestRecordPermission({(granted: Bool)-> Void in if granted { println(" granted") session.setCategory(AVAudioSessionCategoryPlayAndRecord, error: nil) session.setActive(true, error: nil) self

AVAudioRecorder/AVAudioSession with Apple Airpods

巧了我就是萌 提交于 2019-11-29 07:37:59
I see the question already asked here: AirPods not working as an input source for Voice Recorder App I've checked in with this thread but no response. But, does anyone know if/why AVAudioRecorder might not be able to use the AirPods as an input device for recording audio in an app? I have audio recording working through the builtin mics as well as with other BT devices (Beats, cheapo BT speaker phone thing, etc.) but when working with the AirPods I'm unable to capture the audio. In addition when about to record, I'm looping through the available inputs and forcing the input to be the BT device

iOS - AVAudioSession Route Change Notification in background

坚强是说给别人听的谎言 提交于 2019-11-29 06:26:07
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 notifications while in the background - my app is not playing any music at any point, and should not interfere with other apps playing sound The setup: - audio enabled in p-list UIBackgroundModes - in the main controller: // AUDIO AVAudioSession *audioSession = [AVAudioSession sharedInstance]; [audioSession setCategory

Alternative to deprecated AudioSessionGetProperty, for iOS 7

别来无恙 提交于 2019-11-29 06:14:27
问题 I am using AudioSessionGetProperty to check 'audioIsAlreadyPlaying'. Xcode says: 'AudioSessionGetProperty' is deprecated: first deprecated in iOS 7.0 Please could someone tell me what I should use instead, to get the audioIsAlreadyPlaying property. AudioSessionGetProperty(kAudioSessionProperty_OtherAudioIsPlaying, &propertySize, &audioIsAlreadyPlaying); return audioIsAlreadyPlaying; 回答1: Trying using the AVAudioSession 's otherAudioPlaying property on iOS 6.0 or higher. [[AVAudioSession