audiosession

AVAudioPlayer doesn't start playing in background

房东的猫 提交于 2019-12-01 14:24:40
I am using AVAudioPlayer and NSFileHandle to do audio streaming. The basic idea is that I save the streaming audio data to the device with file system and then use AVAudioPlayer to playback the file just saved. AVAudioPlayer can still play that file even the streaming is in progress. I have a UIButton to start streaming/downloading. When the downloaded data is accumulated to a specific amount of Bytes, AVAudioPlayer will play (the "play" method of AVAudioPlayer is triggered) automatically. My question is: I tap the button to start streaming/downloading, then press iPhone's home button very

AVAudioPlayer doesn't start playing in background

╄→гoц情女王★ 提交于 2019-12-01 12:56:22
问题 I am using AVAudioPlayer and NSFileHandle to do audio streaming. The basic idea is that I save the streaming audio data to the device with file system and then use AVAudioPlayer to playback the file just saved. AVAudioPlayer can still play that file even the streaming is in progress. I have a UIButton to start streaming/downloading. When the downloaded data is accumulated to a specific amount of Bytes, AVAudioPlayer will play (the "play" method of AVAudioPlayer is triggered) automatically. My

AudioSession input from bluetooth output to line out or speaker

风格不统一 提交于 2019-12-01 11:24:22
Once an audio session has been set up the following code allows bluetooth input. UInt32 allowBluetoothInput = 1; AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryEnableBluetoothInput, sizeof (allowBluetoothInput), &allowBluetoothInput); This code looks like it only allows bluetooth input however this code also routes the audio output to the bluetooth device (in the case of a bluetooth headset). I would like to route the audio output out of the line out or speaker when the input is coming from a bluetooth device. I just want to get audio input from a bluetooth device, I do not

App with AVPlayer plays mp4 interrupt iPod music after launched

谁都会走 提交于 2019-12-01 09:18:44
My App plays mp4 using AVPlayer, when my application finish launching, it interrupt the iPod music, although I have set the audio session to allow mix with others in - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { AudioSessionInitialize(NULL, NULL, NULL, NULL); AudioSessionSetActive(true); UInt32 sessionCategory = kAudioSessionCategory_AmbientSound; AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory); UInt32 allowMixWithOthers = true; AudioSessionSetProperty(kAudioSessionProperty

AudioSession input from bluetooth output to line out or speaker

帅比萌擦擦* 提交于 2019-12-01 08:21:02
问题 Once an audio session has been set up the following code allows bluetooth input. UInt32 allowBluetoothInput = 1; AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryEnableBluetoothInput, sizeof (allowBluetoothInput), &allowBluetoothInput); This code looks like it only allows bluetooth input however this code also routes the audio output to the bluetooth device (in the case of a bluetooth headset). I would like to route the audio output out of the line out or speaker when the input

Detect (listen to) audio route change in iOS 7

…衆ロ難τιáo~ 提交于 2019-11-30 17:22:23
Just starting development for iOS 7, and found that AudioSession related functions and PropertyListeners are deprecated in iOS 7. Before I use the following method to detect if a headset has been plugged in or unplugged from the device: /* add callback for device route change */ AudioSessionAddPropertyListener ( kAudioSessionProperty_AudioRouteChange, audioRouteChangeListenerCallback, (__bridge void *)(self)); Then implement the listener callback to do different things to the internal algorithms. Now iOS 7 deprecated it and there's no documentations on any alternative, Is there any solutions

headphone plug-in plug-out event when audio route doesn't change - iOS

一个人想着一个人 提交于 2019-11-30 09:43:06
问题 I'm working on iPad. I would like to detect when user plug-out headphone. First I used a listener on the property kAudioSessionProperty_AudioRouteChange . So all was working well until I've decided to add a button to switch to speakers when headphone was still plugged. So I’m now facing a problem, maybe someone would have an idea to fix it. Here is the scenario : I plug a headphone -> my audio route change callback is called then I switch sound to speakers (without unplugging my headphone) ->

How to detect if a bluetooth headset plugged or not IOS 8?

一世执手 提交于 2019-11-30 07:38:59
In my project, I use AVAudioSession to detect any headphone is plugged or unplugged. But in this case, I can't detect when bluetooth device is plugged. Here is my code for headphone state. - (void)audioRouteChangeListenerCallback:(NSNotification*)notification { NSDictionary *interuptionDict = notification.userInfo; NSInteger routeChangeReason = [[interuptionDict valueForKey:AVAudioSessionRouteChangeReasonKey] integerValue]; switch (routeChangeReason) { case AVAudioSessionRouteChangeReasonNewDeviceAvailable: //NSLog(@"AVAudioSessionRouteChangeReasonNewDeviceAvailable"); NSLog(@"Headphone/Line

What kind of routes could I get back from kAudioSessionProperty_AudioRoute property?

谁都会走 提交于 2019-11-30 02:56:11
问题 Apple guy tried to be funny and wrote in the docs: ("Headphone," "Speaker," etc.) What kind of return values are possible in reality? 回答1: He wasn't being funny, those are actual values. The only one I've seen that he didn't outline is "LineOut" 回答2: I ran 'strings' on the CoreMedia framework (iOS4.2 SDK), and the following strings seem reasonable and are grouped together: ReceiverAndMicrophone HeadsetInOut HeadphonesAndMicrophone SpeakerAndMicrophone HeadsetBT LineInOut Default Command was:

AVAudioPlayer, using AmbientSound session, is not playing when app is in background

半城伤御伤魂 提交于 2019-11-29 16:15:30
If this is in the apple doc then I've not been able to find it - hoping someone can help: My app plays occasional short audio clips - I want the audio to mix in with audio playing from other apps in the background like the iPod app - but I also want it to carry on playing these audio clips when the app is running in background. I have set "App plays audio" in the Required Background Modes settings in info.plist (the app is also using location services too so that is also set in there) My app sets up an audio session on applicationDidFinishLaunching: AudioSessionInitialize (NULL,NULL,NULL,NULL)