我在我的VideosView.h中導入了MPMoviePlayerController。 在我VideosView.m我嵌入以下代碼:視頻不顯示在屏幕上
NSString *path2 = [[NSBundle mainBundle] pathForResource:@"myVideo" ofType:@"mp4" inDirectory:@"images"];
NSLog(@"%@", path2);
MPMoviePlayerController *myPlayer = [[MPMoviePlayerController alloc] init];
myPlayer.shouldAutoplay = YES;
myPlayer.repeatMode = MPMovieRepeatModeOne;
myPlayer.fullscreen = YES;
myPlayer.movieSourceType = MPMovieSourceTypeFile;
myPlayer.scalingMode = MPMovieScalingModeAspectFit;
myPlayer.contentURL =[NSURL fileURLWithPath:path2];
myPlayer.view.frame = CGRectMake(0, 0, 500, 500);
myPlayer.scalingMode = MPMovieScalingModeFill;
myPlayer.controlStyle = MPMovieControlModeDefault;
[self addSubview:myPlayer.view];
[myPlayer play];
我發現#2這個例子中,卻無法得到它的工作。鏈接到我的視頻是正確的(是的,它在圖像文件夾中)。我的屏幕上顯示一個500×500像素的黑色矩形(課程框架),但沒有播放視頻。
有些幫助會很大。 W.
真棒!努力可以在本地做到這一點。謝謝! – 2013-04-30 19:27:49