播放 YouTube 视频 iOS 7 时 MPMoviePlayerController 错误 _itemFailedToPlayToEnd [英] MPMoviePlayerController error _itemFailedToPlayToEnd while playing youtube video iOS 7

查看:31
本文介绍了播放 YouTube 视频 iOS 7 时 MPMoviePlayerController 错误 _itemFailedToPlayToEnd的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网络上的几个地方看到了这个,但还没有在任何地方找到答案.

I've seen this mentioned a few places around the web but have yet to find answer anywhere.

我正在使用 ALMovieplayercontroller 库.一切正常,但是当我尝试播放 Youtube 视频时出现错误.

I am using ALMovieplayercontroller library. Everything works fine but when i am trying to play Youtube video it gives me error.

_itemFailedToPlayToEnd:{种类 = 1;新 = 2;旧 = 0;}

编辑

- (void)setContentURL:(NSURL *)contentURL {

    self.movieSourceType = MPMovieSourceTypeStreaming;
    [super setContentURL:contentURL];
    [[NSNotificationCenter defaultCenter] postNotificationName:ALMoviePlayerContentURLDidChangeNotification object:nil];
    [self play];
}

这是我的代码

ALMoviePlayerControls *movieControls = [[ALMoviePlayerControls alloc] initWithMoviePlayer:self.moviePlayer style:ALMoviePlayerControlsStyleDefault];
//[movieControls setAdjustsFullscreenImage:NO];
[movieControls setBarColor:[UIColor colorWithRed:195/255.0 green:29/255.0 blue:29/255.0 alpha:0.5]];
[movieControls setTimeRemainingDecrements:YES];

//assign controls
[self.moviePlayer setControls:movieControls];
[self.view addSubview:self.moviePlayer.view];
self.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;

//THEN set contentURL
[self.moviePlayer setContentURL:[NSURL URLWithString:@"http://www.youtube.com/watch?v=NaosmAGx8NM"]];

我找不到解决方案.

请帮忙.

推荐答案

是的,经过大量研究,我找到了以下解决方案.

Yes after so much researching i found to the following soluction.

MPMoviePlayerController 不会直接播放YouTube 视频.您必须提取视频URL 并将视频URL 设置为MPMoviePlayerController.在此视频播放后.

MPMoviePlayerController directly will not play the youtube videos. you have to extract the video URL and set video URL to MPMoviePlayerController. after this video will be played.

有很多 API 可以提供提取的视频 URL.

There are lots of API available that gives the extracted video URL.

其中一些在下面

XCDYouTubeKit

HCYoutubeParser

但使用此 API 您的申请可能会被拒绝.你应该根据自己的风险使用.

But using this API your application might be rejected. you should have to use on your risk.

播放 youtube 视频的最佳方式是 WebView.

Best way to play youtube videos is the WebView.

这篇关于播放 YouTube 视频 iOS 7 时 MPMoviePlayerController 错误 _itemFailedToPlayToEnd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆