UIImagePickerController AVAudioPlayer - iphone

When I open a UIImagePickerController, I can display the device's camera input stream.
But when I play an AVAudioPlayer with [player play] then the camera stops working.
How can I deal with that?

you can't because UIIMagePickerController is controlling the audio, you will need to use low level AVFoundation in order to do that.
checkout AVCam sample code how to record a movie and add the view as subview , that way you will stay in control of the audio and will be able to play audio.

Related

Issue with MPMoviePlayerController playing an audio after a YouTube Video is opened in a Webview

In one View Controller ViewController1, I have tried to open a You tube video embedded in a UIWebview. It opens in the Movie Player window and then I use the "Done" button to come out of the movie player window. Again in another view controller ViewController2 in the same application, I open a MPMoviePlayerController(MPMoviePlayerController *audioplayer) to play an audio file using streaming. However, it remains in the paused state on opening the player. Even when i call the method [audioplayer play], the application automatically sets back the playback state to paused (i rechecked and it is not done through my code).
But if i reopen the application and in view controller ViewController2 i play the audio alone, then MPMoviePlayerController *audioplayer plays successfully.
Any idea what i might be doing wrong ?
This issue was found to be specific only to ios4.0.
This issue doesnt occur in ios4.1 and above.

Must I save the captured image to the Camera Roll when using UIImagePickerController with source type camera?

From the docs of UIImagePickerController:
When the user taps a button to pick a newly-captured or saved image or
movie, or cancels the operation, dismiss the image picker using your
delegate object. For newly-captured media, your delegate can then save
it to the Camera Roll on the device. For previously-saved media, your
delegate can then use the image data according to the purpose of your
app.
So this reads like I MUST save the captured image to the Camera Roll. Is this true? Reason for rejection if not done?
No, you do not need to save to Camera roll when UIImagePickerController is dismissed. I have done this in several apps.

MPMusicPlayerController not play on background

i am using MPMusicPlayerController in my app and when i enter to background it stop playing.
this is how i add it :
musicPlayer = [MPMusicPlayerController iPodMusicPlayer];
The iPodMusicPlayer is always enabled in the background. You shouldn't have to set anything. And [MPMusicPlayerController applicationMusicPlayer] won't play in the background ever. I'd say you're using the wrong MPMusicPlayerController somewhere.
You need to indicate in your app's plist file that you want to play audio in the background.
you create the applicationMusicPlayer it is not play in back ground.
you have to create ipodMusicPlayer to overcome this.
check this out for further refference.
http://developer.apple.com/library/ios/#documentation/MediaPlayer/Reference/MPMusicPlayerController_ClassReference/Reference/Reference.html#//apple_ref/doc/uid/TP40008221

MPMoviePlayerController vs. MPMoviePlayerViewController

I'm new to iPhone development. Just wondering what the difference is between the MPMoviePlayerController and the MPMoviePlayerViewController. Also, more generally, what is the difference between a controller and a view controller? I know that you use a controller to construct a view (as with MPMoviePlayerController.view), so what does a ViewController create?
The MPMoviePlayerController is just a movie player, it provides a way for you to play movies on the iPhone, a MPMoviePlayerViewController is an actual view controller subclass that takes care of presentation of the MPMoviePlayerController...as documentation at apple puts it
"An MPMoviePlayerController instance, or movie player, manages the playback of a movie from a file or a network stream. Playback occurs either in full-screen mode or in a custom view that is vended by the movie player. You can incorporate the view into your own view hierarchies or use an MPMoviePlayerViewController object to manage the presentation for you."
There is no relation between a viewControler and a controller, this class just happens to be named MPMoviePlayerController because it gives you control over the movie player. Actually before (4.0 i think) there was no view controller and just the movie player, later apple decided to incorporate the movie player view controller too.
Zaius,
In the simplest terms, MPMoviePlayerViewController displays the movie/video using the MPMoviePlayerController.
hence, MPMoviePlayerController is a property in MPMoviePlayerViewController that you can access.
MPMoviePlayerViewController.moviePlayer is the property that you'd use to access MPMoviePlayerController properties.
Hope anyone hitting this thread will find this useful!
Example:
MyMoviePlayerViewController * moviePlayerVC = [[MPMoviePlayerViewController alloc]initWithContentURL:movieURL];
moviePlayerVC.moviePlayer.allowsAirPlay = YES;

Stopping video in viewWillAppear:(bool)animated method

In my viewWillAppear:(bool)animated method I want to stop video playing. How can I do this? I am new I don't know much.
I am playing a video on this screen. I have a tab which shows table view. When I click on the tab the table view is shown but video is playing in background: we can hear the music.
If you are using MPMoviePlayerController, call -pause on that object.