objective c - How do I play YouTube videos with iOS-GTLYouTube library? -


i'm trying play youtube videos using ios-gtlyoutube library. finished query code videos , got few gtlyoutubevideo objects. after got them, what? how play it? i've searched web found nothing.

you can't play videos gtlyoutube library, can use search api video information.

after retrieving video id of video want play, can load id iframe in uiwebview.

nsstring *videoid = @"hcduubr70i8"; // video id returned api query  // adjust width , height liking, pass in view's frame width , 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]]; 

google provides own uiwebview wrapper class, youtube-ios-player-helper, makes youtube video playback on ios devices little easier.


Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -