MPMoviePlayerController 启动时出现问题

发布于 2024-09-02 01:53:57 字数 2057 浏览 6 评论 0原文

我的 MPMoviePlayerController 有问题,因为当我全屏启动它时它存在,但歌曲仍在播放。我添加了 MPMoviePlayerDidExitFullscreenNotification 通知,它表示当视频开始播放时,它会全屏显示。这是我的代码:

_multimediaPlayer = [[MPMoviePlayerController alloc] init];
_multimediaPlayer.controlStyle = MPMovieControlStyleDefault;
_multimediaPlayer.initialPlaybackTime = 0;

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(videoPlayBackDidFinish:) 
                                                 name:MPMoviePlayerPlaybackDidFinishNotification 
                                               object:nil];

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(videoPlayerDidExitFullscreen:) 
                                                 name:MPMoviePlayerDidExitFullscreenNotification
                                               object:nil];

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(videoPlayerPlaybackStateChanged:) 
                                                 name:MPMoviePlayerPlaybackStateDidChangeNotification
                                               object:nil];

    NSString *path = [NSString stringWithFormat:@"%@/mag_%d/%@", [FMUtils documentsFolderPathWithFile:nil], _magID, _pageObject.fileName];
    if ([FMUtils fileExistsAtPath:path]) {
        _multimediaPlayer.contentURL = [NSURL fileURLWithPath:path];
    } else {
        _multimediaPlayer.contentURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@", self.dataURL, _pageObject.fileName]];
    }

    CGSize objectViewSize = self.frame.size;
    _multimediaPlayer.view.frame = CGRectMake(0, 0, objectViewSize.width, objectViewSize.height);
    [self addSubview:_multimediaPlayer.view];

    if (_pageObject.blink)  {
        [_multimediaPlayer setFullscreen:YES animated:YES];
    }

    [_multimediaPlayer play];

大多数情况下,当视频未下载并且需要流式传输时,就会发生这种情况。

您知道为什么会发生这种情况吗?

I have a problem with MPMoviePlayerController, because when I start it in fullscreen it exists, but the song is still playing. I added the MPMoviePlayerDidExitFullscreenNotification notification and it says that when the video starts playin it exists the full screen. Here's my code:

_multimediaPlayer = [[MPMoviePlayerController alloc] init];
_multimediaPlayer.controlStyle = MPMovieControlStyleDefault;
_multimediaPlayer.initialPlaybackTime = 0;

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(videoPlayBackDidFinish:) 
                                                 name:MPMoviePlayerPlaybackDidFinishNotification 
                                               object:nil];

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(videoPlayerDidExitFullscreen:) 
                                                 name:MPMoviePlayerDidExitFullscreenNotification
                                               object:nil];

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(videoPlayerPlaybackStateChanged:) 
                                                 name:MPMoviePlayerPlaybackStateDidChangeNotification
                                               object:nil];

    NSString *path = [NSString stringWithFormat:@"%@/mag_%d/%@", [FMUtils documentsFolderPathWithFile:nil], _magID, _pageObject.fileName];
    if ([FMUtils fileExistsAtPath:path]) {
        _multimediaPlayer.contentURL = [NSURL fileURLWithPath:path];
    } else {
        _multimediaPlayer.contentURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@", self.dataURL, _pageObject.fileName]];
    }

    CGSize objectViewSize = self.frame.size;
    _multimediaPlayer.view.frame = CGRectMake(0, 0, objectViewSize.width, objectViewSize.height);
    [self addSubview:_multimediaPlayer.view];

    if (_pageObject.blink)  {
        [_multimediaPlayer setFullscreen:YES animated:YES];
    }

    [_multimediaPlayer play];

Most of the time it happens when the video is not downloaded and it needs to stream it.

Do you have any idea why is this happen?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

所有深爱都是秘密 2024-09-09 01:53:57

当我不听 MPMoviePlayerPlaybackStateDidChangeNotification 时问题已解决。

Problem solved while I not listen to MPMoviePlayerPlaybackStateDidChangeNotification.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文