我想在ios 6中播放视频。我正在使用Xcode 4.5。我在下面编写代码但收到错误
Test Demo[736:14003] [MPAVController] Autoplay: Disabling autoplay for pause
Test Demo[736:14003] [MPAVController] Autoplay: Disabling autoplay
Test Demo[736:14003] [MPAVController] Autoplay: Skipping autoplay, disabled (for current item: 1, on player: 0)
和我的代码
NSString *videoPath = [[NSBundle mainBundle] pathForResource:@"TestVideo" ofType:@"m4v"];
NSURL *streamURL = [NSURL fileURLWithPath:videoPath];
MPMoviePlayerController *player =
[[MPMoviePlayerController alloc] initWithContentURL: streamURL];
[player prepareToPlay];
[player.view setFrame: self.view.bounds]; // player's frame must match parent's
[self.view addSubview: player.view];
// ...
[player play];`
答案 0 :(得分:1)
您的错误可能存在许多问题。
1)为MPMoviePlayerController
设置属性并进行综合。如果您的MPMoviePlayerController在播放之前发布,则可能会发生这种情况。
2)添加此代码player.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
3)根据documentation,未提及.m4v
分机。
4)下面的屏幕截图将帮助您了解支持的格式。
答案 1 :(得分:1)
NSString *url = [[NSBundle mainBundle] pathForResource:@"santaMessage" ofType:@"mp4"];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:url]];
[self.view addSubview:moviePlayer.view];
moviePlayer.fullscreen = YES;
moviePlayer.allowsAirPlay = YES;
[moviePlayer play];
///这就像一个魅力