Play 2 songs simultaneously,one should play only through Headphones and other through Speakers - iphone

I am using AVPlayer to play two songs simultaneously.
I want to play song on Speaker and before playing i want to check it in headphones only(another song will be playing at the same time in speakers) then i want to play on speakers.Its like prelistening of a song before routing it to Speakers.
Is it Possible on iOS..?

I'd say this would only be possible by used private APIS (if at all) once the iPhone has headphones plugged in everything is routed to it so you'd be trying to change a low-level setting.

Related

play sound while app in call and speaker is occupied by call

My app is a calling app and I want to play a mp3 file during the call (call in my app not the iphone voice call). AvAudioPlayer play return YES so it means sound is played but I do not hear the sound played.
the mp3 file I want to play is a simple small beep sound which I want to play to inform the caller during the call.
Any idea why I can not hear the sound or is there a way for this.
thanks a lot.

Playing and recording Audio simutaneouly with headset jack pin in iOS?

I am developing an iPhone application which requires to play and record Audio(I am doing this with help of AudioQueues) simultaneously. I am using headset jack pin with mic for recording and playing and the playing sound is a wav file of 5kHz.
The problem here is it's recording the sound that is playing out through output AudioQueues as well as the sound that is coming into headset mic. but I need to record only the sound that is coming through the headset mic.
I am unable to find the problem is with the headset jack pins(I have tested with lot off headset jack pins) or any programming settings like AudioSessions. the same is with the AVAudioPlayer and AVAudioRecorder too.
Can anyone tell the problem and some help and suggestions would very helpful. Thanks.
In this case you have to pump the input sound using external amplifier/ mixer. Mic alone will not work properly. If you increase the recording volume in your pc you will hear louder hissing sound and at the same time it will continue to record the playback sound. So the only solution is use external source (amply/mixer) to raise the level of the input mic.

playing ipod library songs in audio queues , not with mpmusicplayer controller

i need to play songs from my music library in the background , while playing video..
Both audio and video will play at the same time... first i tried using mpmusicplayercontroller to play music , but when i play video , its stops playing song in background. after that i tried to play music using audiotoolbox."Audio Queues". now i can play audio and video at the same time ,but the song i am playing is static. i want to play song from ipod library and i need to provide the file path there, so is there any way to get the library song path? or any other idea? please suggest..!
While it may be possible, Apple doesn't want you to know how. They don't want people to be able to programmatically access the song data. It can lead to music sharing, which Apple tries not to make easy.
Maybe the way to do this is to have your videos be the thing that is static and get your songs through MPMusicPlayer. Of course, you'll have to play them with a different mechanism than MPMediaPlayer.

iPhone SDK: how to play music and record from the mic at the same time?

I am trying to play music from the user's music library and at the same time record from the built-in microphone. However, as soon as I start recording from the microphone it automatically pauses the music, and I can't find any way to play music and record at the same time. I am using the MediaPlayer framework to play music and the AudioToolbox framework to record from the mic.
Does anyone know if it is possible to play music and record from the mic at the same time, and if so how to do it?
You set your audio session to kAudioSessionCategory_PlayAndRecord
and create an in/out remote io audio unit.
The "loopy" author talks about how to do this here and provides code.
The trailblazing tones of the article are slightly dated now.
You'll need to set your audiosession properties to allow both recording and playback. This might mean that you need to use AudioToolbox for the playback as well as the recording.
try:
Add #import "CDAudioManager.h"to AppDelegate.m and Add [CDAudioManager
initAsynchronously:kAMM_PlayAndRecord]; to - (void)
applicationDidFinishLaunching:(UIApplication*)application

Using AVAudioPlayer and MPMoviePlayerController simultaneously

I need to use AVAudioPlayer and MPMoviePlayerController simultaneously i.e play a movie while the background loop is playing is it possible.
My bg music loop stops working when a movie starts playing , so I tried to stop the bg music loop and start the movie and when movie stops, start playing the bg loop again but this is also is not working.
In fact it is achievable from 3.x onwards. I had once done this in one of my applications and its got nothing to do with any backgrounding or any other new iOS features. You just need to configure the audio sessions properly. If you make sure that both your audio player as well as the video player are using the ambient audio session it is possible.
Prior to starting your AVAudioPlayer to play, set the category of audio session to AVAudioSessionCategoryAmbient. This is the system wide common audio session. This allows other sounds to play along such as the sound from the iPod application.
In case you are using the MPMoviePlayerController from iOS 3.2 or above make sure you set the useApplicationAudioSession to NO. This ensures other sounds to play along. It is the default in earlier versions of iOS.
There is a limitation in the current iPhone SDK (2.x and 3.x) that does not allow any background audio playing while a movie is playing in the MPMoviePlayerController API. Unfortunately, it is not possible to do what you are asking at this time within the iPhone SDK.
I would suggest logging an enhancement request to Apple to offer this in a future version of the SDK.