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

查看:111
本文介绍了播放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:{
kind = 1;
new = 2;
old = 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视频。您必须提取视频网址并将视频网址设置为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可用于提取视频网址。

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天全站免登陆