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을 제공합니다.
출처
2016-02-11 03:33:49
JAL