iOS - Have 3rd-Party app play to AirPlay device while my app plays audio locally
iOS - Have 3rd-Party app play to AirPlay device while my app plays audio locally
- Subject: iOS - Have 3rd-Party app play to AirPlay device while my app plays audio locally
- From: über rätsel <email@hidden>
- Date: Tue, 15 Oct 2013 16:26:54 -0600
Is it possible for an iOS device to play audio to the local built-in
speaker, headphone, or earpiece while another 3rd-Party app streams to
an AirPlay device?
Potential Use Case: A user wishes to stream to an AirPlay device using
an internet service such as Pandora while playing a game in another
app. The game has an audio soundtrack and realtime sound mixing and
effects and it only makes sense to play its audio to the local output.
Here are some ideas I've looked at:
1. Set the session category to AVAudioSessionCategoryPlayAndRecord and
use theoverrideOutputAudioPort option to force audio output to a
particular route. Something like:
AVAudioSession *session=[AVAudioSession sharedInstance];
NSError *error;
BOOL result=[session
overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker
error:&error];
Unfortunately, this doesn't appear to do the trick. Using this
technique, if I load my app first and then try going to another app,
it prevents the AirPlay icon from even showing up in some apps. For
the apps that still show the AirPlay icon, it shows only two options,
"iPhone Speaker" and "iPhone". Playing to the "iPhone Speaker" plays
through the built-in speakers. Playing to "iPhone" plays to the
earpiece. If I load my app last, it stops the AirPlay output of the
other app and begins playing the output locally.
2. Use the "System Sound Services" APIs to force the OS to play the
audio locally, and not to the AirPlay device selected by the 3rd-Party
app. According to the docs, "The sound is played locally on the device
speakers; it does not use audio routing." This is precisely what I
want!
Unfortunately this has its limitations. Audio bytes are limited to 30
seconds, must be in either .caf .aif or .wav formats, and cannot be
mixed. Not to mention, using the System Sound Services to achieve this
functionality is a misuse of the API.
Does anybody have any other ideas?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden