avaudiosession

Low recording volume in combination with AVAudioSessionCategoryPlayAndRecord

℡╲_俬逩灬. 提交于 2019-11-27 18:11:42
When I set: [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayAndRecord error:NULL]; …recording and playing works fine, just the playback volume is around 60% lower than when I would just play the same sound without recording and settings PlayAndRecord. I need to get high volume peaks (to check if a user blow in the mic) for that i started a recording session. But without settings AVAudio..PlayandRecord, i can not playback any sounds in the meantime. Thats the reason i implemented this command. Any Help? Thx Chris christian Muller For everyone with the same problem,

iOS 9 How to Detect Silent Mode?

倖福魔咒の 提交于 2019-11-27 16:20:53
问题 As AudioSessionInitialize and AudioSessionGetProperty are deprecated, I am getting the wrong return values: CFStringRef state = nil; UInt32 propertySize = sizeof(CFStringRef); AudioSessionInitialize(NULL, NULL, NULL, NULL); OSStatus status = AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize, &state); [[AVAudioSession sharedInstance] setActive:YES error:nil]; if (status == kAudioSessionNoError) { return CFStringGetLength(state) == 0; // YES = silent } return NO; From this

Audio Player play in background and should work based off of hardware mute switch

丶灬走出姿态 提交于 2019-11-27 14:07:44
问题 I want to play audio file in the foreground, background and it should work with mute switch i.e. if mute switch is on, then it should not play, if mute switch is off should play audio. **I'm developing an SIP call application. App should play sound/ringtone when user receives a call. It should play if app is in background/foreground, it should mute/unmute if hardware mute switch is ON/OFF. For this I used AVPlyaer with below code. AVAudioSession *session = [AVAudioSession sharedInstance];

List available output audio target AVAudioSession

僤鯓⒐⒋嵵緔 提交于 2019-11-27 13:34:46
问题 I need to list the audio outputs available to an iOS application. My question is similar to this one: How to list available audio output route on iOS i tried this code: NSError *setCategoryError = nil; BOOL success = [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: &setCategoryError]; NSError *activationError = nil; [[AVAudioSession sharedInstance] setActive: YES error: &activationError]; … NSLog(@"session.currentRoute.outputs count %d", [[[[AVAudioSession

Unable to switch to speaker output when bluetooth headsets are connected

余生颓废 提交于 2019-11-27 06:32:26
问题 I'm trying to allow for a toggle between bluetooth headsets (airpods in my case) and the phone speaker, using AVAudioSession . I initialize my session as so: AVAudioSessionCategoryOptions options = (AVAudioSessionCategoryOptionAllowBluetooth | AVAudioSessionCategoryOptionDefaultToSpeaker); NSError *error = nil; [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:options error:&error]; Then I try to alternate between output modes as so: -(void

How to mute/unmute audio when playing video using MPMoviePlayerController?

坚强是说给别人听的谎言 提交于 2019-11-27 04:26:02
问题 I've created my own custom controls for use with the MPMoviePlayerController . So far everything works except the mute button control. I've configured the AVAudioSession using the following code before I create my instance of the MPMoviePlayerController . NSError *modeError = nil; [self.audioSession setMode:AVAudioSessionModeMoviePlayback error:&modeError]; if (modeError != nil) { NSLog(@"Error setting mode for AVAudioSession: %@", modeError); } NSError *categoryError = nil; [self

How to change an iOS device volume programmatically?

╄→尐↘猪︶ㄣ 提交于 2019-11-27 03:20:25
问题 Is there a way to change the device volume programmatically? maybe using audio session? 回答1: I'm pretty sure that it is not possible to control the actual device volume (as this would also be a bit obtrusive) Controlling some media you're playing is another thing. You could however look into MPVolumeView : https://developer.apple.com/library/ios/documentation/MediaPlayer/Reference/MPVolumeView_Class/index.html for displaying a view for setting the volume. The question has also been discussed

Receive remote control events without audio

一个人想着一个人 提交于 2019-11-27 02:20:08
问题 Here is some background information, otherwise skip ahead to the question in bold. I am building an app and I would like it to have access to the remote control/lock screen events. The tricky part is that this app does not play audio itself, it controls the audio of another device nearby. The communication between devices is not a problem when the app is in the foreground. As I just found out, an app does not assume control of the remote controls until it has played audio with a playback

AVCaptureSession and background audio iOS 7

拟墨画扇 提交于 2019-11-27 01:09:36
Whenever I start an AVCaptureSession running with the microphone as an input it cancels whatever background music is currently running (iPod music for instance). If I comment out the line adding the audio input, the background audio continues. Does anyone know a way to record video clips with the microphone while continuing to allow background audio to play? Also there is error, when you trying to record video and the music is currently playing. A tried to do like this: [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: nil]; UInt32 doSetProperty = 1;

Are headphones plugged in? iOS7

随声附和 提交于 2019-11-26 23:38:51
Developing an app for an iPhone with audio files that need to be listened too through headphones. How do I check if headphones aren't plugged in so I can tell the user to plug in headphones. I have the following code from another thread but the audioSessionGetProperty method is deprecated. Anyone know how to alter the following code to make this work OR have there own code/solution. Thanks. - (BOOL)isHeadsetPluggedIn { UInt32 routeSize = sizeof (CFStringRef); CFStringRef route; //Maybe changing it to something like the following would work for iOS7? //AVAudioSession* session = [AVAudioSession