1
我正在開發一個需要在應用程序中播放教程視頻的mac應用程序。當用戶按下應用按鈕應該發揮的視頻 這裏是對的Xcode 4.3代碼在OSX中播放視頻
@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];
}
我使用的Xcode 5.1 OSX 10.8
感謝會看看它是否工作 – 2014-09-05 00:31:20
是它與OSX 10.8 Xcode的5一樣的嗎? – 2014-09-05 01:47:33
如何在窗口加載時自動播放視頻? – 2014-10-01 05:35:17