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.
Related
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];
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];
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];
each time my app changes the displayed animation, which is a looping movie, he takes a pause till he finally start the movie.
The MoviePlayerConntroller is created this way
self.moviePlayer = [MPMoviePlayerController alloc];
[moviePlayer initWithContentURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:#"NewChar" ofType:#"m4v"]] ];
// remove playerview from our view (no prob is he isnt attached to any)
[moviePlayer.view removeFromSuperview];
// tell our playerview the size he has to use
moviePlayer.view.frame = CGRectMake(0, 0, 320, 430);
// and add hin to the superview behind everything else
[self.view insertSubview:moviePlayer.view atIndex:0];
// no moviecontrolls
moviePlayer.controlStyle = MPMovieControlStyleNone;
// looping forever
moviePlayer.repeatMode= MPMovieRepeatModeOne;
// let him use his own Audio Session for old devices
moviePlayer.useApplicationAudioSession= NO;
// fix the silly black background on iOS 4.3
moviePlayer.view.backgroundColor = [UIColor clearColor];
the actual movie is played this way
[moviePlayer initWithContentURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:#"Whatever" ofType:#"m4v"]]];
[moviePlayer play];
Just as I said, each time the movie is changed, he takes a while to display it. On newer devices its ok, since they are faster, but on G2 it is somewhat disturbing.
Tried prepare playback, but that makes no difference.
Any idea what I missed?
Thanks for reading! :)
It takes time to load up the movie from disk, and obviously will be slower on older devices. How big is the video?
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.