avaudiosession

IOS: Play sound while app in background

匆匆过客 提交于 2019-12-03 14:30:01
I working on a little app where i want the phone to play a sound file on an event from my location controller. The problem is when the App is in Background mode the AVAudioPlayer not start the Audio file but the code is scheduled, getting NSLog output. Another thing is it works in the simulator but not on the phone. Whys not? This is my code to play the file: - (void)tryPlayTaleSound:(NSString*)fileName { NSString *backgroundMusicPath = [[NSBundle mainBundle] pathForResource:fileName ofType:@"mp3"]; NSURL *backgroundMusicURL = [NSURL fileURLWithPath:backgroundMusicPath]; NSError *error;

Setting AVAudioSession Category has no effect on sound from WKWebView

倖福魔咒の 提交于 2019-12-03 13:55:42
I can not seem to override the AVAudioSession category or port when audio is being played from a WKWebView. The same code works perfectly when using a normal UIWebView. AVAudioSession *session = [AVAudioSession sharedInstance]; [session setCategory:AVAudioSessionCategoryPlayAndRecord error:&err]; I've also tried activating the sharedInstance like this, but it did not help: [session setActive: YES error: nil]; The above code has no effect on audio coming from a WKWebView. I did find some reports on Twitter that iOS 8.1 is mixing WKWebView audio with background app audio, but I couldn't find the

Camera Freeze when open app while call is running

感情迁移 提交于 2019-12-03 13:13:28
问题 I have created a camera using AVCaptureSession . I have configured that for both Photo and Video recording modes . Camera and App is running fine. Also I allowed background music play (If user play song using Music App in iPhone) while open camera or recording video. It is also working fine. (Attached image 2) I allowed background Music play with the help of this code AVAudioSession *session1 = [AVAudioSession sharedInstance]; [session1 setCategory:AVAudioSessionCategoryPlayAndRecord

ObjectAL automatic interruption handling error

最后都变了- 提交于 2019-12-03 13:06:43
I've been playing with phone calls while (SpriteKit)game running in order to test interruptions. I am using example from ObjectAL documentation called : "Using the OpenAL Objects and OALAudioTrack" . So, I let the library to handle this automatically... [OALAudioSession sharedInstance ]. handleInterruptions = YES And it works but partially. For example, with simple setup with 3 sounds I get next error message : OALAudioSession activateAudioSession]: Could not activate audio session after 2 tries: Error Domain=NSOSStatusErrorDomain Code=561015905 "The operation couldn’t be completed. (OSStatus

AVAudioSession / Audio Session Services switching output

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 12:59:44
Okay, I have my AVAudioSession defined with the following (yes, mix of the c and obj-c calls) Also note that the app has background mode audio, because if recording it must continue to do so while the app is in the background: [(AVAudioSession *)[AVAudioSession sharedInstance] setDelegate: self]; // Allow the app sound to continue to play when the screen is locked. [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord error:nil]; //Turn off automatic gain on the microphone [[AVAudioSession sharedInstance] setMode:AVAudioSessionModeMeasurement error:nil]; //Turn on

Cocos2D 2.1: “Delegate” deprecated in iOS 6. How do I set the delegate for this AVAudioSession?

北战南征 提交于 2019-12-03 12:50:36
问题 Started a Cocos2D 2.1 template (with no physics engine) in Xcode 4.5, targeted for iOS 6 and iPad. In the CDAudioManager.m file, the following code... AVAudioSession* session = [AVAudioSession sharedInstance]; session.delegate = self; // Which is what is automatically generated by the template. ...generates the following warning... "delegate deprecated: first deprecated in iOS 6" So I go to the apple developer documentation, and it says under "delegate," "Deprecated in iOS 6.0. Use the

AVSpeechSynthesizer error AudioSession

…衆ロ難τιáo~ 提交于 2019-12-03 11:14:40
问题 I'm playing around with AVSpeechSynthesizer and always getting these errors: ERROR: >aqsrv> 65: Exception caught in (null) - error -66634 ERROR: AVAudioSessionUtilities.h:88: GetProperty_DefaultToZero: AudioSessionGetProperty ('disa') failed with error: '?ytp' My code is: AVSpeechSynthesizer *synthesizer = [[AVSpeechSynthesizer alloc] init]; [synthesizer setDelegate:self]; speechSpeed = AVSpeechUtteranceMinimumSpeechRate; AVSpeechUtterance *synUtt = [[AVSpeechUtterance alloc] initWithString:[

What's the difference among AVAudioSessionPortBluetoothHFP, A2DP and LE?

半城伤御伤魂 提交于 2019-12-03 07:31:37
There are three different Bluetooth related audio port types documented in Apple's AVAudioSessionPortDescription reference. But Apple doesn't explain much about these three types. Can somebody help explain more? AVAudioSessionPortBluetoothHFP | Input and Output This is used when connected to a bluetooth devices through Hands-Free profile, like cars or earpieces. It can be accessed by setting your audio session category to AVAudioSessionCategoryPlayAndRecord and category option AVAudioSessionCategoryOptionAllowbluetooth . AVAudioSessionPortBluetoothA2DP | Output only This is mainly used for

AVAudioSession AVAudioSessionCategoryPlayAndRecord glitch

耗尽温柔 提交于 2019-12-03 07:30:24
问题 I would like to record videos with audio using AVCaptureSession . For this I need the AudioSessionCategory AVAudioSessionCategoryPlayAndRecord , since my app also plays back video with sound. I want audio to be audible from the default speaker and I want it to mix with other audio. So I need the options AVAudioSessionCategoryOptionDefaultToSpeaker | AVAudioSessionCategoryOptionMixWithOthers . If I do the following while other audio is playing there is a clear audible glitch in the audio from

iOS: Deprecation of AudioSessionInitialize and AudioSessionSetProperty

淺唱寂寞╮ 提交于 2019-12-03 07:21:59
I'm very new to Objective-C, and am trying to update some code that's about 3 years old to work with iOS 7. There are two or two instances of AudioSessionSetProperty and AudioSessionInitialize appearing in the code: 1: - (void)applicationDidFinishLaunching:(UIApplication *)application { AudioSessionInitialize(NULL,NULL,NULL,NULL); [[SCListener sharedListener] listen]; timer = [NSTimer scheduledTimerWithTimeInterval: 0.5 target: self selector: @selector(tick:) userInfo:nil repeats: YES]; // Override point for customization after app launch [window addSubview:viewController.view]; [window