2

iOS6でビデオを再生したかったのですが、Xcode4.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

エラーには多くの問題がある可能性があります。

1)のプロパティを設定し、MPMoviePlayerController合成します。これは、MPMoviePlayerControllerが再生前にリリースされた場合に発生する可能性があります。

2)このコードを追加しますplayer.moviePlayer.movieSourceType = MPMovieSourceTypeFile;

3)ドキュメントによると、.m4v拡張機能は再生するように言及されていません。

4)以下のスクリーンショットは、サポートされている形式について役立ちます。

ここに画像の説明を入力してください

于 2012-10-30T06:16:13.853 に答える
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 に答える