0

これは私がビデオを再生している機能ですが、サウンドのみを再生し、ビデオは表示されていません

  -(void)playMovieAtURL:(NSString *)moviePath
    {   
        NSURL *movieURL=[NSURL URLWithString:moviePath];

        MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];

        NSLog(@"url : %@",movieURL);

        [player setControlStyle:MPMovieControlStyleDefault];

        [player setScalingMode:MPMovieScalingModeAspectFit];

        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieDidExitFullscreen:) name:MPMoviePlayerPlaybackDidFinishNotification object:player];

        [[player view]setFrame:[[self view]bounds]];
        [[self view] addSubview:[player view]];

        [player play];

    }
4

1 に答える 1

0

MPMoviePlayerControllerは単なるムービープレーヤーであり、それが理にかなっている場合は、実際にはムービーの表示を処理しません。ビデオを独自のビュー階層に埋め込む必要がある場合にのみ、MPMoviePlayerControllerを使用する必要があります。フルスクリーンで再生していて、カスタムコントロールについて言及しているため、これを行う必要があるようには思えません。代わりに、MPMoviePlayerViewControllerを使用してみてください。URLからムービーをロードし、ネイティブコントロールでビデオを表示するために必要なすべてを実行します。あなたのURLでMPMoviePlayerViewControllerをインスタンス化し、それをモーダルビューとして表示するだけです。

MPMoviePlayerViewController *player = [[MPMoviePlayerViewController alloc]initWithContentURL:[NSURL urlWithString:moviePath]];
[self presentModalViewController:player];
[player release];
于 2011-07-06T16:45:22.037 に答える