Why won't my movie play using MPMoviePlayerController?
Posted
by
Nosrettap
on Stack Overflow
See other posts from Stack Overflow
or by Nosrettap
Published on 2012-09-16T03:32:36Z
Indexed on
2012/09/16
3:37 UTC
Read the original article
Hit count: 141
I'm trying to get a basic movie to play in an iPhone app; however, I can't seem to get it to work. Here's my entire code:
#import <MediaPlayer/MediaPlayer.h>
#import "ViewController.h"
@implementation ViewController
- (IBAction)playMoviePressed:(id)sender
{
NSURL *url = [NSURL URLWithString:@"http://www.ebookfrenzy.com/ios_book/movie/movie.mov"];
MPMoviePlayerController *moviePlayer =
[[MPMoviePlayerController alloc] initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
moviePlayer.controlStyle = MPMovieControlStyleDefault;
moviePlayer.shouldAutoplay = YES;
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];
[moviePlayer prepareToPlay];
[moviePlayer play];
}
@end
I have one button on screen that calls playMoviePressed
when it is tapped. I know that this method is getting called. I have also tried this with .mov
and .mp4
local files that I have dragged into xcode.
© Stack Overflow or respective owner