[cpp] view plaincopyprint?在.h文件導入庫文件
在.h文件導入庫文件[cpp]
#import <MediaPlayer/MPMoviePlayerViewController.h>
#import <MediaPlayer/MPMoviePlayerViewController.h>
[cpp] view plaincopyprint?在.m實現文件中
在.m實現文件中[cpp]
NSString *path=[[NSBundle mainBundle] pathForResource:@"name" ofType:@"mp4"];
NSURL *URL = [[NSURL alloc] initFileURLWithPath:path];
MPMoviePlayerViewController *_moviePlayerController = [[MPMoviePlayerViewController alloc] initWithContentURL:URL];
[[self GetViewController:self.view] presentMoviePlayerViewControllerAnimated:_moviePlayerController];
[_moviePlayerController.moviePlayer play];
NSString *path=[[NSBundle mainBundle] pathForResource:@"name" ofType:@"mp4"];
NSURL *URL = [[NSURL alloc] initFileURLWithPath:path];
MPMoviePlayerViewController *_moviePlayerController = [[MPMoviePlayerViewController alloc] initWithContentURL:URL];
[[self GetViewController:self.view] presentMoviePlayerViewControllerAnimated:_moviePlayerController];
[_moviePlayerController.moviePlayer play];