如何在osx autoplay中制作avplayer?
我试过这个:
NSURL *videoURL = [[NSBundle mainBundle]
URLForResource:@"video name" withExtension:@"mp4"];
self.movieView.player = [AVPlayer playerWithURL:videoURL];
Run Code Online (Sandbox Code Playgroud)
它没有自动播放?
我正在开发一个需要在应用程序中播放教程视频的mac应用程序.当用户按下应用程序上的按钮时,它应播放视频,这里是xcode 4.3的代码(与xcode 5.1不兼容)
@synthesize movieView;
-(IBAction)playVideo:(id)sender {
NSString *videoPath = [[NSBundle mainBundle] pathForResource:"video name" ofType:@"mp4";
NSURL *videoURL = [NSURL fileURLWithPath: videoPath];
NSError *error = nil;
NSDictionary *attrib = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES],
QTMovieOpenForPlaybackAttribute,
videoURL, QTMovieURLAttribute,
[NSNumber numberWithBool:YES],
QTMovieOpenAsyncRequiredAttribute, nil];
QTMovie *newMovie = [[QTMovie alloc] initWithAttributes: attrib error: &error];
[movieView setMovie:newMovie];
[movieView play:newMovie];
}
Run Code Online (Sandbox Code Playgroud)
我正在使用xcode 5.1 for osx 10.8