Skip to content

Instantly share code, notes, and snippets.

@doyle
Created June 23, 2009 03:29
Show Gist options
  • Save doyle/134340 to your computer and use it in GitHub Desktop.
Save doyle/134340 to your computer and use it in GitHub Desktop.
// This gist demonstrates how to play a movie on the iPhone
// This code sample assumes you have a file called "Movie.m4v" in your Resources folder, and
// have /included the MediaPlayer Framework (/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/System/Library/Frameworks/MediaPlayer.framework)
#import <MediaPlayer/MediaPlayer.h>
...
-(IBAction)playMovie:(id)sender{
NSBundle *bundle = [NSBundle mainBundle];
NSString *moviePath = [bundle pathForResource:@"Movie" ofType:@"m4v"];
NSURL *movieURL = [NSURL fileURLWithPath:moviePath];
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
[mp play];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment