2014-11-12 6 views
1

iOS-GTLYouTube 라이브러리를 사용하여 YouTube 동영상을 재생하려고합니다. 방금 내 동영상에 대한 쿼리 코드를 완료하고 몇 개의 GTLYouTubeVideo 개체를 얻었습니다. 그래서 내가 그들을 얻은 후에, 무엇? 어떻게해야합니까? 나는 웹을 수색했지만 아무 것도 발견하지 못했다.iOS-GTLYouTube 라이브러리로 YouTube 동영상을 재생하려면 어떻게해야하나요?

답변

0

GTLYouTube 라이브러리로 동영상을 재생할 수 없으며, 동영상 정보 용 API 만 검색 할 수 있습니다.

재생할 비디오의 비디오 ID를 검색 한 후 해당 ID를 UIWebView의 iFrame에로드 할 수 있습니다.

NSString *videoID = @"HCdUubr70i8"; // the video ID returned from your API query 

// Adjust the width and height to your liking, I just pass in the view's frame width and height 
NSString *str = [NSString stringWithFormat:@"<html><body style='margin:0px;padding:0px;'><script type='text/javascript' src='http://www.youtube.com/iframe_api'></script><script type='text/javascript'>function onYouTubeIframeAPIReady(){ytplayer=new YT.Player('playerId',{events:{onReady:onPlayerReady}})}function onPlayerReady(a){a.target.playVideo();}</script><iframe id='playerId' type='text/html' width='%@' height='%@' src='http://www.youtube.com/embed/%@?enablejsapi=1&rel=0&playsinline=1&autoplay=1' frameborder='0'></body></html>", self.view.frame.size.width, self.view.frame.size.height, videoID]; 


UIWebView *webView = [UIWebView ...]; 
[webView loadHTMLString:embedHTML baseURL: [[NSBundle mainBundle] bundleURL]]; 

구글은 iOS 기기 좀 더 쉽게에 YouTube 동영상 재생을하게 자신의 UIWebView 래퍼 클래스, youtube-ios-player-helper을 제공합니다.