Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

naphatkrit

macrumors member
Original poster
Jul 18, 2011
38
0
Hi,
I'm trying to get a video to play in my app. I've googled this and followed quite a few tutorial, to no success. I'm just met with a blank dark screen. Here is my code:

Code:
 NSString *resourcePath = [[NSBundle mainBundle] pathForResource:@"recording5" ofType:@"mov"];
    self.moviePlayer = [[MPMoviePlayerController alloc]initWithContentURL:[NSURL URLWithString:resourcePath]];
    [self.moviePlayer.view setFrame:self.view.bounds];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish) name:MPMoviePlayerPlaybackDidFinishNotification object:self.moviePlayer];
    
    self.moviePlayer.controlStyle = MPMovieControlModeDefault;
    self.moviePlayer.shouldAutoplay = YES;
    [self.view addSubview:moviePlayer.view];
    [self.moviePlayer setFullscreen:YES animated:YES];

moviePlayer is a variable I declared in my .h file.
Is there something wrong with my code? The video is a screen recording from Quicktime X with the resolution set to match that of the iPad.
 
Last edited:
Yeah there is something wrong :p
First of all, MPMovieController doesn't support MOV coding. Second, there are some newer versions of the MPMovieController, I think "MPMoviePlayerViewController" is the correct one :), you should use that one instead for better manipulation.
Also, I found that MOV isn't supported in 10 seconds of google search >.>
 
Wow I had no idea .mov isn't supported. I assumed that it is supported because I was able to use iTunes to sync it over to the iPad and play normally from the Video app. What format do you recommend?
I'll also try MPMoviePlayerViewController, but if the problem is with the format, I don't think tell work.

Thank you so much for getting back to me so quickly :) Love this forum!
 
yes you have one think wrong in your code.......

you are using "MPMoviePlayerController" it is wrong way to calling.... if you use "MPMoviePlayerViewController" then you got no error and your streaming will going accurately.
 
He doesn't have any streaming, with on device "movies", MOV isn't supported, MP4 is your best bet. (most native+support encoded). If it works, head back.
And the newer version I showed you, you can also add as a subview, and just resize like you want it to, I think this was introduced since 4.x something.
In the beginning video's were only full screen, so they changed it to a new one, you can assign your current movieController to the pointer of the Playerview.movieplayer or something if I remember correctly, rest of the code should be nearly the same.
 
I tried your suggestions and went with MPMoviePlayerViewController and .mp4 format. Now, the video control screen does come up, but the content is still black, and this is shown in the log:

Code:
2012-06-26 15:56:22.439 videoNew[2277:13a03] [MPAVController] Autoplay: Likely to keep up or full buffer: 0
2012-06-26 15:56:22.442 videoNew[2277:13a03] [MPAVController] Autoplay: Skipping autoplay, not enough buffered to keep up.

What does this mean?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.