我在Xcode 4中用SDK 4.3创建了我的iPhone应用。
在我的iPhone应用中,我使用了MPMovieplayercontroller,并使用它来播放视频。
它是在我的iPod Touch与IOS 4.3播放我的视频文件,但如果我安装相同的项目在我的iPad与iOS 5,它只是显示黑屏,但不播放视频。
可能是什么问题?
以下是.h文件中的代码
MPMoviePlayerController *moviePlayer;
.m文件中
-(void)playVideo{
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"testbild1" ofType:@"m4v"]];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
UIView *testview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
[testview addSubview:moviePlayer.view];
[self.view addSubview:testview];
}
- (void)moviePlaybackComplete:(NSNotification *)notification
{
MPMoviePlayerController *moviePlayerController = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayerController];
[moviePlayerController.view removeFromSuperview];
}
看起来你并没有设置自动播放。
shouldAutoplay
A Boolean that indicates whether a movie should begin playback automatically.
@property (nonatomic) BOOL shouldAutoplay
所以喜欢。
moviePlayer.shouldAutoplay = true;
你也应该可能打电话 prepareToPlay
并从 MPMediaPlayback
协议书 MPMoviePlayerController
实施
老帖子(应该是评论)。
什么版本的iOS? iOs 5.1测试版刚出来,改变了MPMoviePlayerController的工作方式。
你可以在Apple的iOS测试版网站上获得详细信息,但我不能在这里打印出来YAY EULA。
现在操作系统已经公开了,这里有相关的文档(注册--你可能也要交100元,我忘了......)。
prepareToPlay
在该页面上--没有深层链接)