views:

1295

answers:

3

Hello everybody...

I have been fighting some code for about a week, and am hoping that someone else may have experienced this problem and can point me in the right direction.

I am using the MPMoviePlayerViewController to play a video on the iPad. The primary problem is that it works FLAWLESSLY on the iPad Simulator, but will not play at all on the iPad. I have tried re-encoding the video to make sure that isn't an issue. The video I'm using is currently a 480x360 video encoded with H.264 Basline 3.0 with AAC/LC audio. The video plays fine on the iPhone, and also does play through Safari on the iPad. The video actually loads, and you can scrub through the video with the scrubber bar and see that it is there. The frames actually display, but just will not play. If you click play, it just immediately stops. Even when I have mp.moviePlayer.shouldAutoplay=YES set, you can see the player attempt to play, but only for a split second (maybe 1 frame?).

I have tried just adding view with the following code:

in .h
------
MPMoviePlayerViewController          *vidViewController;

@property (readwrite, retain)     MPMoviePlayerViewController *vidViewController;




in .m
------

MPMoviePlayerViewController *mp=[[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:videoURL]];
[mp shouldAutorotateToInterfaceOrientation:YES];
mp.moviePlayer.scalingMode=MPMovieScalingModeAspectFit;
mp.moviePlayer.shouldAutoplay=YES;
mp.moviePlayer.controlStyle=MPMovieControlStyleFullscreen;
[videoURL release];


self.vidViewController = mp;
[mp release];

[self.view addSubview:vidViewController.view];

float w = self.view.frame.size.width;
float h = w * 0.75;

self.vidViewController.view.frame = CGRectMake(0, 0, w, h);

I have also just tried to do a:

[self presentMoviePlayerViewControllerAnimated:self.vidViewController];

which I actually can not get to orient properly...always shows up in Portrait and almost completely off the screen on the bottom, and the app is only intended to run in either of the Landscape views...

If anybody needs more info, just let me know. I'm about at my wits end on this. ANY help will be GREATLY appreciated.

+1  A: 

You may want to try shutting down the iPad (powering off), remove and re-install the app.

John

iPhoneDevTips

John
John, I have seen this on the developer forum as well. I was able to get the video to play successfully by doing this. The only problem is that this does not explain what causes it, or how to prevent it. Basically eventually it will not play again, and this requires another remove and reinstall to get it to play again.
Symo
Symo, I hear you, my concern as well, what's the real source of the problem? Sounds like an issue on the device/software itself.
John
A: 

Just add a line after you add the movie player to the view:

[self.vidViewController.moviePlayer play];

See if it helps.

Thanks,

Madhup

Madhup
Thank you for your reply, but I have already tried that. I have also tried changing states several times, evening pause then play, etc. Still all has the same result.
Symo
+1  A: 

I see 2 problems here.

First you are not setting the frame of the view. Try adding

mp.view.frame = self.view.frame;

This is what fixed it for me.

Next the shouldAutorotateToInterfaceOrientation does not need to be called. This method simply tells you if the view supports an orientation. Check the Apple docs.

Kevin