0

ストリーミングビデオの全画面表示を開始し、ユーザーが「完了」ボタンを押すのをやめさせる簡単な方法を書いています。問題は、MPMediaPlayerController ビューを削除できないか、間違った方法で行っていることです。

- (IBAction)playVideoButtonPressed:(id)sender {
    NSURL *url = [NSURL URLWithString:@"http://mysite.com/video.mov"];
    mp = [[MPMoviePlayerController alloc] initWithContentURL: url];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(moviePlayerPlaybackDidFinish:)
                                             name:MPMoviePlayerPlaybackDidFinishNotification
                                           object:nil];

    if ([mp respondsToSelector:@selector(setFullscreen:animated:)]) {  
        mp.controlStyle = MPMovieControlStyleFullscreen;  
        mp.shouldAutoplay = YES;
        [self.view addSubview:mp.view];  
        [mp.view setTag:3];
        [mp setFullscreen:YES animated:YES];  
    }
    [[NSNotificationCenter defaultCenter] addObserver:self            
        selector:@selector(moviePlayBackDidFinish:) 
        name:MPMoviePlayerPlaybackDidFinishNotification
        object:mp];

    [mp play];
}

- (void)moviePlayBackDidFinish:(id)sender {
      NSLog(@"Quitting MoviePlayer");
      [mp.view removeFromSuperview];    
}

アプリのボタンをクリックすると MPMediaPlayerController ビューが呼び出され、「完了」ビデオをクリックするか、ビデオが終了するとビューが閉じられるという考え方です。

4

1 に答える 1

0

MPMoviePlayerViewController を使用する必要がありました。

于 2011-10-31T14:35:39.640 に答える