MPMusicPlayerController not play on background - iphone

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

Related

How can I stop playing a movie?

How can I stop playing a movie?
I want to stop a playing a movie, when I use MPMoviePlayerController to play a movie.
Just use [movieController stop], should do the trick. It's defined in the MPMediaPlayback Protocol.

UIImagePickerController AVAudioPlayer

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.

Stop iPad MoviePlayer video when a view is changed

I'm writing my first iPad app that plays a video on a portion of the screen. My problem is that if the user changes to another view while the video is playing, the audio keeps playing in the background. I assume I have to add something to the "viewDidUnload" method but I'm not sure what to do. Any ideas? Thanks for any info.
You can try adding
[myMoviePlayer pause]; // assume myMoviePlayer is an instance variable
[myMoviePlayer stop];
myMoviePlayer = nil;
to your viewWillDisappear method.

How do I play music using MPMusicPlayerController?

Can any one suggest me how to play the music using MPMusicPlayerController in my application.
Anyone's help will be very much appreciated.
Thank you,
Monish.
Create a MPMediaPickerController so you can choose some music from the iPod,
then in the mediaPicker:didPickMediaItems: call back you do this:
MPMusicPlayerController* playa;
playa = [MPMusicPlayerController applicationMusicPlayer];
[playa setQueueWithItemCollection:mediaItemCollection];
[playa play];

iPhone MPMoviePlayer hide movie Control

hi i want hide movie control (Play - next - volume and ..)from MPMoviePlayer ...
what can i do ?
You can do this by this line of code
which hides the controls of the
player.
[player setMovieControlMode:MPMovieControlModeHidden];
Haven't tried it, but isn't there a setHidden:YES you can do?
iOS 3.2 and later use "setControlStyle" e.g.
[player setControlStyle:MPMovieControlStyleNone];
Check out the movieControlMode property of MPMoviePlayerController. You'll probably want MPMovieControlModeHidden.