How to play Playlist in MPMoviePlayerController in iPhone? - iphone

I would like to play List of movie files(.mp4) from my application using MPMoviePlayerController. I created Player using following code, but i can see only three buttons to play, fastforward and backward. Does default MPMoviePlayerController has Previous and Next button to play next and previous video in my list. If it is avilable how can we bring those button in my controller and if is not avilable how can we achive it by customizing MPMoviePlayerController.
movie = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
// movie.controlStyle = MPMovieControlStyleNone;
[movie setControlStyle:MPMovieControlStyleFullscreen];
[movie.view setFrame:CGRectMake(30, 15, 400, 250)];
[self.view addSubview:movie.view];
[self registerForMediaPlayerNotifications];
[movie play];

Related

How can i add a video as a HUD element in iphone sdk

I want to add a video that shows up when i call it but not a typical (stretch-to-bounds) view
similar to the ProgressHud view that loads in the middle and darkens the background. how can I load a video say from LBYoutubeController or natively?
Thanks!
edit: ideally the video box will take up 60-70 % of the screen but again will be centered and overshadowing the background
You need to use a MPMoviePlayerController. You can set the controlStyle to MPMovieControlStyleEmbedded and this will give you a player with no controls. Set the scalingMode to MPMovieScalingModeFill to make the video conform to the frame you set for it regardless of the video's natural layout. Just add the movie player's view to your view hierarchy and you're good to go.
MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] init];
moviePlayer.scalingMode = MPMovieScalingModeFill;
moviePlayer.controlStyle = MPMovieControlStyleEmbedded;
[myView addSubview:moviePlayer.view];
To add a dimming view behind this:
UIView *back = [[UIView alloc]initWithFrame:myView.bounds];
back.backgroundColor = UIColor.blackColor;
back.alpha = 0.7;
[myView insertSubview:back belowSubview:myView];

Display video in full screen inside table view cell

I have one scrollview inside which i have displayed tableview. I have custom cell and i want to display video on click on that. It's working nicely but when i am clicking on full screen button my application gets crashed. So how can i resolve this issue..
My code to display video is given below.
MPMoviePlayerController *moviePlayer= [[MPMoviePlayerController alloc] initWithContentURL:url];
moviePlayer.view.frame = CGRectMake([cordinate.x integerValue], [cordinate.y integerValue], [cordinate.width integerValue], [cordinate.height integerValue]);
moviePlayer.controlStyle = MPMovieControlStyleEmbedded;
[cell addSubview:moviePlayer.view];
[moviePlayer prepareToPlay];
Please help me to solve this..
Add this line and then check it work or not:
moviePlayer.view.frame = self.view.frame;
and remove this line [addSubview:moviePlayer];

mpmovieplayercontroller issue

one small issue in my movieplayer..![movieplayer shows like this]
1: http://i.stack.imgur.com/WujxB.png but i want to show as below screenshot
mycode:
moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
moviePlayerController.view.frame = CGRectMake(0,0,320,460);
moviePlayerController.fullscreen = YES;
[self.view addSubview:moviePlayerController.view];
[moviePlayerController play];
Those are the default controls for fullscreen playback, since you set moviePlayerController.fullscreen = YES.
The controls you want are for embedded playback, not fullscreen.
What you want is moviePlayerController.controlStyle = MPMovieControlStyleEmbedded; but you can only use it if your movie is embbeded in one of your views. Then you would have the controls that you want, including a toggle between fullscreen and embedded.
You have to use MPMoviePlayerViewController instead of using MPMoviePlayerController.

MPMoviePlayerController visible while loading stream

Any one know how to keep the MPMoviePlayerController visible while the movie is loading.
Or before the movie is ready to play?
For some reason it only shows up when the Movie is ready to play.
Heres what I have.
mp = [[MPMoviePlayerController alloc] initWithContentURL:url];
[self.view addSubview:[mp view]];
mp.view.frame = mediaPlayerContainer.frame;
[mediaPlayerContainer removeFromSuperview];
mp.useApplicationAudioSession = YES;
mp.shouldAutoplay = YES;
mp.controlStyle = MPMovieControlStyleFullscreen;
My mediaPlayerContainer is just a dummy container so I can visually build a frame for my mp view.
The only other thing I can think of doing is using a "screenshot" of a player as a place holder. And removing it if the player is in "play" mode.
That seems janky though.
Thnks.
MPMoviePlayerController has a backgroundView property...
You can add an UIImageView to it and it should be displayed while it is loading the video.

Hide MPMoviePlayerController while new video loads

I have an iPad app that has 4 buttons on the left side that corresponds to 4 different video clips. When a user taps the video they want to see, it appears on the right side. I am wanting it to appear to be loading (as if it were streaming over the internet). I added the UIActivityIndicator to the center of the black video frame and have a thread that pauses for 3 seconds. However, the player containing the previous video does not disappear. It just freezes on the last frame of the previous video for 3 seconds (hiding the activity indicator) and then the new video appears.
Any ideas on how to make the player temporarily be hidden? Thanks for any help. Here is my code:
-(IBAction) videoButton1{
[player stop];
[player release];
[self.activityIndicator startAnimating];
NSString *url = [[NSBundle mainBundle] pathForResource:#"video1" ofType:#"mov"];
[self setupVideoPlayer:url];
}
-(void) setupVideoPlayer: (NSString *) url{
player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url)];
player.view.frame = CGRectMake(487, 205, 478, 320);
[self.view addSubview:player.view];
[NSThread sleepForTimeInterval:3.0];
self.activityIndicator stopAnimating];
[player play];
}
You can set the frame of your player to a View that you can make in IB or programmatically instead of doing a CGRectMake every time.
self.player.view.frame =
self.viewForMovie.bounds;
self.player.view.autoresizingMask =
UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleHeight;
Then in your "videoButton1" you can set the alpha of the View to 0
viewForMovie.alpha = 0;
And in your "setupVideoPlayer" you can change the alpha back to 1.