Record video iphone and play a sound - iphone

How i can record video and play a sound at the same time? I am having trouble doing so. I am using AVFoundation

Set audio session category to AVAudioSessionCategoryPlayAndRecord?

Related

Recording audio and playing iPod at the same time?

I am trying to be able to record audio through the iPhone's microphone while simultaneously playing music from the iPod.
The recording and playback work separately, but if I try to playback from the iPod and record at the same time the recording stops.
By the way, I am not actually recording the audio to save the sound file, but merely analyzing it. It's for my app that flashes to the beat of the music you play.
Does Apple just not allow record and playback at the same time?
You should be able to do this by setting the Audio Session to AVAudioSessionCategoryPlayAndRecord. Information on this is in the Apple docs, although admittedly the Core Audio documentation is (and has always been) lacking in clarity.
AVSession Class Reference
Also, it's worth noting that AVAudioRecorder and AVAudioPlayer automatically set the session for you. You can wrestle control and set the session manually using the key I highlighted above.
the problem may be you are recording audio to the same path where the playing file is saved.
try to play an audio from a url with AVAudioPlayer and you can record with AVAudioRecorder at the same time.
Cheers :) :)

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.

how can we play audio and video together in ipod/iphone?

HI all
i am playing a video(.mp4 format) without sound (i mean it doesn't have sound it is a mute video ) and in the background i am playing an audio file (.mp3 format) when i play my code through simulator it works fine as i want like when i tap on the video it is just mute but behind i am playing the audio so for user it seems that video has this sound but when i installed my code in device and play video than it doesn't work like so it play video but without sound than how can i play an audio and a video together in the above format ?
actually we are not just playing a single video or audio file it just comes from an array by choosing randomly and same for the audio file so we cann't do this i think so any other idea for it ??
Should we use another format for audio aur video for doing this thing ??
thanks for the help
Balraj verma
The problem is that the default Audio Session does not allow audio mixing.
In the Reference Library (Working with Movie Players) they say you should use a mixable category configuration for your audio session, for example the Ambient category. In the Application Delegate:
AVAudioSession *audioSession = [AVAudioSession sharedInstance];
NSError *setCategoryError = nil;
[audioSession setCategory:AVAudioSessionCategoryAmbient error: &setCategoryError];
Apple's documentation states that some audio formats are not suited to be played back simultaneously because of hardware restrictions. See Playing Multiple Sounds Simultaneously for more details.
A solution for you would be to use PCM encoded audio which should allow simultaneous playback.
I would like to add that I managed to play two mp3 audio files at the same time on 3G and 3GS iPhones. Which shouldn't be possible according to documentation but worked for me.
You can rather use the an instance of AvAudioPlayer in a new thread. Use the following link to see how does this work
http://www.mobileorchard.com/easy-audio-playback-with-avaudioplayer/
create an instance of MPMoviePlayer to start playback of videos.
Hope this will work.
You should combine the audio and video using some video editing software like iMovie or Windows Movie Maker. Using the software to "composite" audio and video together is not a good idea and adds additional overhead, synchronization issues, etc.
As far as I know, you can't play AVAudioPlayer and MPMoviePlayer at the same time.

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

Which format support the audio file with a playing video?

i am playing the video and in the background i have to play the audio file and if i do this audio is not playing its sound as it just play video is it a extension problem i am using the .mp3 for the audio and .mp4 for the video .
how can we do this we have to play simultanisouly .both the file
balraj verma
Have a look at this:
http://developer.apple.com/iphone/library/documentation/MusicAudio/Conceptual/CoreAudioOverview/CoreAudioEssentials/CoreAudioEssentials.html#//apple_ref/doc/uid/TP40003577-CH10-SW67
"To play multiple sounds simultaneously, create one playback audio queue object for each sound. For each audio queue, schedule the first buffer of audio to start at the same time using the AudioQueueEnqueueBufferWithParameters function.
Audio format is critical when you play sounds simultaneously on iPhone or iPod touch. This is because playback of certain compressed formats in iPhone OS employs an efficient hardware codec. Only a single instance of one of the following formats can play on the device at a time:
AAC
ALAC (Apple Lossless)
MP3"