【发布时间】:2012-03-17 05:21:23
【问题描述】:
这是我的代码
-(IBAction)playvideo:(id)sender
{
NSLog(@"Get in");
NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"video3" ofType:@"MOV"];
MPMoviePlayerController *movie = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:moviePath]];
NSLog(@"movie path %@",moviePath);
NSLog(@"movie %@",movie);
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieViewFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:movie];
movie.controlStyle = MPMovieControlStyleDefault;
movie.shouldAutoplay = YES;
[self.view addSubview:movie.view];
[movie setFullscreen:YES animated:YES];
[movie play];
}
这是我的日志
2012-03-16 16:54:39.080 TestVideofile[510:11f03] 进入 2012-03-16 16:54:39.303 TestVideofile[510:11f03] 影片路径 /用户/crazyoxy/图书馆/应用程序支持/iPhone 模拟器/5.1/Applications/7F1425B8-6DB0-4A09-AC8F-3BCDBF19ED95/TestVideofile.app/video3.MOV 2012-03-16 16:54:39.304 TestVideofile[510:11f03] 电影
单击与此 IBAction 链接的按钮后,它变为黑页,但没有显示视频甚至任何音频。
你能帮帮我吗?
【问题讨论】:
-
您是否在实际设备而不是模拟器上尝试过这个? (我可以看到你正在运行我是你的日志)。
-
还没有。我的设置有问题,所以我不能用我的 iPad 运行 :( 哦,video3.MOV 是我用 iPhone4 录制的电影,所以我认为视频文件也不会有任何错误。
-
嗯,我用另一台 iPad 运行,但它仍然显示黑页。 :(
-
dude try
NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"video3.MOV" ofType:nil];实际上我很久以前就遇到了同样的问题,我认为类型更改已经解决了我的问题。试着让我知道 -
我只是更改了我的代码,现在它是 WORKKK 但没有意义。我将 MPMoviePlayerController *movie 移动到 .h 文件。和属性并合成它。它工作 - 你能告诉我它为什么工作吗?我不明白。顺便说一句,非常感谢:D
标签: objective-c ios video xcode4 mpmovieplayercontroller