使用MPMoviePlayerController播放电影时隐藏状态

时间:2010-05-26 05:06:40

标签: iphone

我已使用[[UIApplication sharedApplication] setStatusBarHidden:YES];隐藏了应用中的状态栏。但是当我播放电影时,它会自动显示顶部的状态栏。

有谁知道如何在播放电影时隐藏状态栏。

2 个答案:

答案 0 :(得分:0)

您可以订阅MPMoviePlayerPlaybackStateDidChangeNotification通知,并确保在播放开始后立即隐藏状态栏。

您的处理程序看起来像这样:

- (void)playbackStateDidChange:(NSNotification *)notification {
    MPMoviePlayerController *mpv = (MPMoviePlayerController *)notification.object;
    if (mpv.playbackState == MPMoviePlaybackStatePlaying) {
        [[UIApplication sharedApplication] setStatusBarHidden:YES];
    }
}

答案 1 :(得分:0)

MPMoviePlayerViewController *playercontroller = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:path]];
    [AppShare.viewController presentMoviePlayerViewControllerAnimated:playercontroller];
    //[self.view addSubview: playercontroller.view];
    [self.view addSubview:playercontroller.view];
    playercontroller.moviePlayer.view.frame = CGRectMake(0.0, 0.0, 320.0, 480.0);
    playercontroller.moviePlayer.scalingMode = MPMovieScalingModeAspectFill;
    playercontroller.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
    playercontroller.moviePlayer.controlStyle = MPMovieControlStyleNone;
    [playercontroller.moviePlayer prepareToPlay];
    [playercontroller.moviePlayer play];
    playercontroller = nil;