mazzica1
mazzica1

Reputation: 71

embedded youtube videos in uiwebview are no longer working

i was using uiwebview to play embded youtube video but today as sudden it stopped working any one knows work around?

    NSString* videoHTML = [NSString stringWithFormat:@"\
                       <html>\
                       <head>\
                       <style type=\"text/css\">\
                       iframe {position:absolute; top:50%%; margin-top:-130px;}\
                       body {background-color:#000; margin:0;}\
                       </style>\
                       <script type=\"text/javascript\" src=\"https://www.youtube.com/player_api\"></script>\
                       <script>\
                       var player;\
                       function onYouTubeIframeAPIReady() {\
                       player = new YT.Player('player',{ events: {\
                       'onReady': onPlayerReady}\
                       });}\
                       function onPlayerReady(event) {\
                       setTimeout(function() {\
                       event.target.playVideo();\
                       }, 1000);\
                       }\
                       </script>\
                       </head>\
                       <body>\
                       <iframe class=\"youtube-player\" background-color:#000000 allowtransparency= \"true\" type=\"text/html\" width=100%% height=240px src=\"http://www.youtube.com/embed/%@?fs=1&autoplay=1&rel=0&version=3&enablejsapi=1&showinfo=0\" frameborder=\"0\" allowfullscreen/>\
                       </body>\
                       </html>",self.videoID];
[self.webView loadHTMLString:videoHTML baseURL:nil];
[webView setAllowsInlineMediaPlayback:YES];

Upvotes: 0

Views: 1179

Answers (2)

mazzica1
mazzica1

Reputation: 71

i changed the whole html to only reffere to mobile version of youtube site

Upvotes: 0

kubakal
kubakal

Reputation: 11

Change /embed/... to /v/... and it'll work fine.

Upvotes: 1

Related Questions