视频 – MPMoviePlayerController在完成播放后不会自动关闭电影(ios 6)

前端之家收集整理的这篇文章主要介绍了视频 – MPMoviePlayerController在完成播放后不会自动关闭电影(ios 6)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我可能没有写出我的标题很好,也许更正确的说,我的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`

解决方法

也有这个问题
要修复moviePlayBackDidFinish
只是添加
player.fullscreen = NO;

在从视图中删除视图之前

原文链接:https://www.f2er.com/iOS/330445.html

猜你在找的iOS相关文章