2

我想在 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];`
4

2 回答 2

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];

///这就像一个魅力

于 2013-12-02T07:48:06.143 回答
1

您的错误可能有很多问题。

1)为你设置一个属性MPMoviePlayerController并合成它。如果您的 MPMoviePlayerController 在播放之前释放,则可能会发生这种情况。

2)添加此代码player.moviePlayer.movieSourceType = MPMovieSourceTypeFile;

3)根据文档.m4v未提及扩展名。

4)下面的屏幕截图将帮助您了解支持的格式。

在此处输入图像描述

于 2012-10-30T06:16:13.853 回答