2014-01-24 151 views
1

我已开始使用XCDYouTubeVideoPlayer。它似乎有一些小问题。当我使用方法(如下图)调用播放器时,它会立即打开并关闭它。XCDYouTubeVideoPlayer打开和关闭

我已经导入以下框架: mediaplayer AVfoundation

,并添加了`XCDYouTubeVideoPlayerViewController.h和.M

在viewController.m我已经添加了这种方法:

- (IBAction) play:(id)sender 
{ 
[self.view endEditing:YES]; 
    NSString *link = @"m01MYOpbdIk"; 

XCDYouTubeVideoPlayerViewController *videoPlayerViewController = [[XCDYouTubeVideoPlayerViewController alloc] initWithVideoIdentifier:link]; 

[self presentMoviePlayerViewControllerAnimated:videoPlayerViewController]; 
} 

目前它的开放和关闭XCDYouTubeVideoPlayer正确的方式。我究竟做错了什么?

+0

如果你纠正这个问题,我希望它会帮助NSURL * videoInfoURL = [NSURL URLWithString:[NSString stringWithFormat:@“https://www.youtube.com/get_video_info?video_id=%@%@ &ps = default&eurl =&gl = US&hl =%@“,self.videoIdentifier?:@”“,elField,ApplicationLanguageIdentifier()]]; – kagmanoj

+0

我找到了,我会试着看看这条线来确定问题。 thx – user3195388

+0

您应该升级到最新版本的[XCDYouTubeKit](https://github.com/0xced/XCDYouTubeKit)(以前称为XCDYouTubeVideoPlayerViewController) – 0xced

回答

0

XCDYouTubeVideoPlayer库通过在提供的签名后附加url来构建youtube“流链接”。看来,“URL”现在有签名与它一起和

(NSURL *) videoURLWithData:(NSData *)data error:(NSError * __autoreleasing *)error

转到文件中使用“SIG”键来空,这从而否定了if语句的功能

XCDYouTubeVideoPlayerViewController.m at #248

你会看到一个for循环

for (NSString *streamQuery in streamQueries) 
{ 
    NSDictionary *stream = DictionaryWithQueryString(streamQuery, queryEncoding); 
    NSString *type = stream[@"type"]; 
    NSString *urlString = stream[@"url"]; 
    NSString *signature = stream[@"sig"]; 
    if (urlString && signature && [AVURLAsset isPlayableExtendedMIMEType:type]) 
    { 
    NSURL *streamURL = [NSURL URLWithString:[NSString   
            stringWithFormat:@"%@&signature=%@", 
            urlString, 
            signature]]; 
    streamURLs[@([stream[@"itag"] integerValue])] = streamURL; 
    } 

改变这种(从if语句删除该签名变量和修改URLWithString)

for (NSString *streamQuery in streamQueries) 
{ 
    NSDictionary *stream = DictionaryWithQueryString(streamQuery, queryEncoding); 
    NSString *type = stream[@"type"]; 
    NSString *urlString = stream[@"url"]; 
    if (urlString && [AVURLAsset isPlayableExtendedMIMEType:type]) 
    { 
    NSURL *streamURL = [NSURL URLWithString:urlString]; 
    streamURLs[@([stream[@"itag"] integerValue])] = streamURL; 
    } 
1

我不明白为什么,但对我来说,在iOS8上线

XCDYouTubeVideoPlayerViewController.m at #79 

是调用方法:

- (id) initWithContentURL:(NSURL *)contentURL 
{ 
     @throw [NSException exceptionWithName:NSGenericException reason:@"Use the 
     ` initWithVideoIdentifier:` method instead." userInfo:nil]; 
} 

我只是评论它,作品!