avaudiosession

Switching audio output between Receiver and Speaker in iOS7 and above?

时间秒杀一切 提交于 2019-12-04 08:52:41
I have an audio player which has an option of switching the Audio Output from Speaker to Receiver/Earpiece (irrespective of whether headset is connected) when proximity sensor notifies 1. The following is my code for doing so. - (void) switchAudioOutput:(NSString*)output{ AVAudioSession* audioSession = [AVAudioSession sharedInstance]; BOOL success; NSError* error; if([output isEqualToString:keAudioOutputReciever]){ //Force current audio out through reciever //set the audioSession override success = [audioSession overrideOutputAudioPort:AVAudioSessionPortOverrideNone error:&error]; if (!success

OSStatus NSOSStatusErrorDomain

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 04:22:40
I received the following error when I get the property using AudioSessionGetProperty(kAudioSessionProperty_CurrentHardwareSampleRate,&size, &myAudioDescription.mSampleRate) Error Produced by above statement is Error Domain=NSOSStatusErrorDomain Code=560557673 "The operation couldn’t be completed. (OSStatus error 560557673.)" Now, here what does 560557673 mean and where can I find its explanation? Documentation only provides NSOSStatusErrorDomain as one of the errors. That code means the property data size was not correct. OSStatus is a type commonly used for error codes in OS X and iOS. If the

Can't play audio recorded from voice using AVCaptureAudioDataOutputSampleDelegate

空扰寡人 提交于 2019-12-03 21:13:42
问题 I have been googling and researching for days but I can't seem to get this to work and I can't find any solution to it on the internet. I am trying to capture my voice using the microphone and then playing it through the speakers. Here is my code: class ViewController: UIViewController, AVAudioRecorderDelegate, AVCaptureAudioDataOutputSampleBufferDelegate { var recordingSession: AVAudioSession! var audioRecorder: AVAudioRecorder! var captureSession: AVCaptureSession! var microphone:

setPreferredHardwareSampleRate doesn't work

筅森魡賤 提交于 2019-12-03 20:48:13
I'm using the code that can be found here . I've tried to change sample rate using: [[AVAudioSession sharedInstance] setPreferredHardwareSampleRate:SAMPLE_RATE error:nil]; Inside the init function on SoundRecoder.m file. (SAMPLE_RATE is 16000.0) When I'm checking the file it seems that still the metadata says the sample rate is 44100, I've tried also to use (as suggested here ): AudioSessionSetProperty ( kAudioSessionProperty_PreferredHardwareSampleRate ,sizeof(F64sampleRate) , &F64sampleRate ); When F64sampleRate is 16000 but still same failure. Does the device can choose which rate to sample

AVAudioRecorder not recording in background after audio session interruption ended

和自甴很熟 提交于 2019-12-03 19:09:08
问题 I am recording audio in my app, both in foreground and in background. I also handle AVAudioSessionInterruptionNotification to stop recording when interruption begins and start again when it ends. Although in foreground it works as expected, when app is recording in background and I receive a call it doesn't start again recording after call ends. My code is the following: - (void)p_handleAudioSessionInterruptionNotification:(NSNotification *)notification { NSUInteger interruptionType = [[

Resume background audio after AVAudioPlayer is paused

六眼飞鱼酱① 提交于 2019-12-03 17:22:15
I've developed an iPhone application that allows other apps to play audio in the background. To achieve this, I initialize my audio session like this: [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil]; At some point in my application I provide an audio player to play some files stored in CoreData with AVAudioPlayer. When the user hits the play button, the background audio should be paused. When the player has finished or is paused, the background audio should resume playback. While resuming after the player has finished playback with -(void

Play system sound while recording video/audio

孤街浪徒 提交于 2019-12-03 16:58:23
I'm trying to play a "beep" sound as required by apple when I start recording a video. I've found through SO and other sources that you can't play a sound while you have an audio input going without some configuration. Here's my attempt at the configuration method: private void SetupAudio() { beepSound = AssetBank.GetSystemSoundWav("video_record", "video_beep"); AudioSession.Initialize(); AudioSession.Interrupted += delegate { Console.WriteLine("Interrupted handler"); }; AudioSession.Category = AudioSessionCategory.PlayAndRecord; AudioSession.OverrideCategoryMixWithOthers = true; NSError err;

Is it possible to add track title to “Now Playing Controls” menu as Music app or ITunesU do?

烈酒焚心 提交于 2019-12-03 16:26:49
I'm, creating a player app. I've implemented 'remoteControlReceivedWithEvent:' method and could change playing state by this buttons ( apple guide ). But when something playing from 'Music' or 'iTunes U' apps, than there are a song title appear under remote controls. Is there any way to show there my own text from my player app? Thanks in advance. Yes, it's done through the MPNowPlayingInfoCenter 来源: https://stackoverflow.com/questions/9384965/is-it-possible-to-add-track-title-to-now-playing-controls-menu-as-music-app-or

How to make MPMoviePlayerController ignore the mute switch

泄露秘密 提交于 2019-12-03 16:16:34
问题 I want to play a video using MPMoviePlayerController but I want it to ignore the mute switch, similar to the behavior of Youtube's video player. Any ideas? 回答1: Use the AVAudioSession category AVAudioSessionCategoryPlayback and your app will ignore the mute switch like the Youtube app. For example (inspired by Ken Pletzer in the comments): #import <AVFoundation/AVFoundation.h> // note: you also need to add AVfoundation.framework to your project's // list of linked frameworks NSError *error =

AVAudioRecorder records only the audio after interruption

纵然是瞬间 提交于 2019-12-03 14:32:01
In my application for recording and playing audio using AVAudioRecorder and AVAudioPlayer I came across a scenario in the case of incoming phone call.While the recording is in progress and if the phone call comes,the audio recorded after the phone call is only recorded.I want the recording recorded after the phone call to be the continuation of the audio recorded before the phone call. I track the interruption occuring in audio recorder using the AVAudioRecorderDelegate methods (void)audioRecorderBeginInterruption:(AVAudioRecorder *)avRecorder and (void)audioRecorderEndInterruption: