【问题标题】:MPMoviePlayerController will not automatically dismiss movie after finish playing (ios 6)MPMoviePlayerController 播放完成后不会自动关闭电影(ios 6)
【发布时间】:2012-10-08 17:35:14
【问题描述】:

我可能没有很好地措辞我的标题,也许更正确的说法是我的 NSNotification 并没有在我的电影播放完成后关闭它的视图。我发现其他人有这个问题但没有解决方案,似乎这可能是我正在运行的 iOS 6 的问题。

视频播放完毕后,您需要按“完成”关闭,但我希望它自动关闭,因为一旦我解决了这个问题,我将使用 MPMovieControlStyleNone。这是我的代码,去掉了未使用的部分: `

#import "MovieViewController.h"

@interface MovieViewController ()

@end

@implementation MovieViewController

@synthesize moviePlayer = _moviePlayer;

- (IBAction)playMovie:(id)sender
{
    NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
                                         pathForResource:@"TestMovie" ofType:@"mov"]];
    _moviePlayer =
    [[MPMoviePlayerController alloc]
     initWithContentURL:url];

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(moviePlayBackDidFinish:)
                                                 name:MPMoviePlayerPlaybackDidFinishNotification
                                               object:_moviePlayer];

    _moviePlayer.controlStyle = MPMovieControlStyleDefault;
    _moviePlayer.shouldAutoplay = YES;
    [self.view addSubview:_moviePlayer.view];
    [_moviePlayer setFullscreen:YES animated:NO];
}

- (void) moviePlayBackDidFinish:(NSNotification*)notification {

    MPMoviePlayerController *player = [notification object];

    [[NSNotificationCenter defaultCenter] removeObserver:self
                                                    name:MPMoviePlayerPlaybackDidFinishNotification
                                                  object:player];

    if ([player
         respondsToSelector:@selector(setFullscreen:animated:)])
    {
        [player.view removeFromSuperview];
    }
}

@end`

【问题讨论】:

    标签: video ios6 mpmovieplayercontroller movie nsnotification


    【解决方案1】:

    也有这个问题 在moviePlayBackDidFinish中修复 只需添加

    player.fullscreen = NO;
    

    在从父视图中删除视图之前

    【讨论】:

    • 我需要倒过来。我希望 MPMoviePlayerController 不应该被自动关闭。用户可以使用完成按钮将其关闭
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多