1

UICollectionViewCell で再生する mp4 ムービーを取得しようとしています。私はそれを表示する運がありません。だから、私の最初の質問は: これは可能ですか? もしそうなら、私は何を間違っていますか?これは ARC 以外のプロジェクトであり、XIB やストーリーボードは使用していません...

NSURL * theURL = nil;
NSBundle * bundle = [NSBundle mainBundle];
if (bundle)
{
     NSString * thePath = [bundle pathForResource:@"intro" ofType:@"mp4"];
     if ( thePath )
     {
         theURL = [NSURL fileURLWithPath:thePath];
     }
}

MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL: theURL];
[player prepareToPlay];
[player.view setFrame: self.contentView.bounds];  // player's frame must match parent's
[self.contentView addSubview: player.view];
[player play];
[player release];
4

1 に答える 1

1

プレーヤーを解放しているように見えるので、割り当てが解除されています。

最後のリリースをコメントアウトして、それが修正されるかどうかを確認してください。その場合は、参照をどこかに保存し (メンバー ivar/セルのプロパティ?)、後で解放する必要があります。

于 2013-02-28T22:44:55.663 に答える