无法在MPMoviePlayer中播放视频

时间:2013-11-08 13:56:16

标签: ios ipad mpmovieplayercontroller mpmovieplayer

我需要使用“MPMoviePlayerViewController”播放视频,当我从库中选择一个视频并将其URL传递给播放器时,它播放约2秒钟并停止响应(根本没有交互),并在控制台中找到这些行< / p>

[MPAVController] Autoplay: Enabling autoplay
[MPAVController] Autoplay: Skipping autoplay, disabled (for current item: 0, on player: 1)
[MPAVController] Autoplay: Enabling autoplay
[MPCloudAssetDownloadController] Prioritization requested for media item ID: 0
[MPAVController] Autoplay: Skipping autoplay, disabled (for current item: 0, on player: 1)
[MPAVController] Autoplay: _streamLikelyToKeepUp: 0 -> 1
[MPAVController] Autoplay: Disabling autoplay for pause
[MPAVController] Autoplay: Disabling autoplay
[MPAVController] Autoplay: Disabling autoplay for pause
[MPAVController] Autoplay: Disabling autoplay
[MPAVController] Autoplay: Disabling autoplay for pause
[MPAVController] Autoplay: Disabling autoplay
[MPAVController] Autoplay: Disabling autoplay
[MPAVController] Autoplay: Skipping autoplay, disabled (for current item: 1, on player: 0)
[MPAVController] Autoplay: Enabling autoplay
[MPAVController] Autoplay: Likely to keep up or full buffer: 0
[MPAVController] Autoplay: Skipping autoplay, not enough buffered to keep up.
[MPCloudAssetDownloadController] Prioritization requested for media item ID: 0
[MPAVController] Autoplay: Likely to keep up or full buffer: 1
[MPAVController] Autoplay: Enabling autoplay
[MPAVController] Autoplay: _streamLikelyToKeepUp: 0 -> 1
[MPAVController] Autoplay: Enabling autoplay
[MPAVController] Autoplay: Likely to keep up or full buffer: 0
[MPAVController] Autoplay: Skipping autoplay, not enough buffered to keep up.
[MPAVController] Autoplay: Enabling autoplay
[MPAVController] Autoplay: Skipping autoplay, disabled (for current item: 0, on player: 1)
[MPAVController] Autoplay: Enabling autoplay
[MPAVController] Autoplay: Skipping autoplay, disabled (for current item: 0, on player: 1)

我已经尝试过“stackoverflow”中的所有内容,但没有用,任何人都可以向我推荐解决方案。

设备:iPad-3,版本:6.1

请建议

以下是我在播放视频时使用的代码

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    NSString* mediaType = [info objectForKey:UIImagePickerControllerMediaType];

    if([mediaType isEqualToString:(NSString*)kUTTypeMovie])
    {
        [self playVideoWithURL:[info objectForKey:UIImagePickerControllerMediaURL]];
    }
}


- (void)playVideoWithURL:(NSURL*)fileURL
{
    if(!self.playerViewController)
    {
        self.playerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:fileURL];
        [self.moviePlayerContainer addSubview:self.playerViewController.view];
        self.playerViewController.moviePlayer.scalingMode = MPMovieScalingModeNone;
        self.playerViewController.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
        [self.playerViewController.moviePlayer stop];
    }
    else
    {
        self.playerViewController.moviePlayer.contentURL = fileURL;
    }

    CGRect movieFrame = self.moviePlayerContainer.frame;
    movieFrame.origin = CGPointZero;
    self.playerViewController.view.frame = movieFrame;
}

1 个答案:

答案 0 :(得分:0)

这种情况的发生仅仅是因为该电影不是本地存储的,而是试图通过iCloud逐步下载。

您的网络带宽(针对iCloud)无法应对该视频,因为其需求过高。

如果没有您的日志,您会看到如下行:

  

可能跟上或完全缓冲:0

这就像玩家的早期警告,告诉你它很可能不会足够快地加载数据以便流畅播放。

另一个重要的部分是这一行

  

[MPCloudAssetDownloadController]请求媒体的优先级   料品ID:0

那个告诉你系统正在远程下载电影。它试图确保其他可能的并行下载应该等待这个,但显然没有足够的带宽(因为没有更多的可用)。

我担心,你无法直接做些什么。

您需要先从iCloud下载该视频,否则您需要降低其质量(重新编码)。