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

straber

macrumors member
Original poster
Jul 3, 2012
60
0
I'm trying to use a MPMoviePlayerController to play a movie, but all I get is a black screen. Any ideas why this is? Here's the code I'm using.

Code:
- (void)playVideo:(ChatMessage *)msg {
    NSURL *movieURL = msg.videoURL;
    self.player = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
    [self.player prepareToPlay];
    [self.player.view setFrame: self.view.bounds];  
    [self.player play];
}

Thanks for any help...
 
Last edited:
How are you presenting your movie player's view? Have you confirmed that you have a valid URL? Have you done any other debugging? If so, what?
 
I'm trying to use a MPMoviePlayerController to play a movie, but all I get is a black screen. Any ideas why this is? Here's the code I'm using.

Code:
- (void)playVideo:(ChatMessage *)msg {
    NSURL *movieURL = msg.videoURL;
    self.player = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
    [self.player prepareToPlay];
    [self.player.view setFrame: self.view.bounds];  
    [self.player play];
}

Thanks for any help...

You are missing a key part. You create a movie player controller, but never add it's view to your view.

you meed a line like this:

Code:
[self.view addSubView self.player.view];

Otherwise the movie player's view will not be displayed anywhere.
 
Thanks for your help,

that's exactly what I was missing, I mistakenly forgot to add the players view as a subview.

Code:
[self.view addSubview:self.player.view];

fixed the problem.

I can't believe I didn't catch that. Damn, it's been a long week. Lol.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.