2

I want to add youtube player in iOS project. Sometimes some approaches works some not. Some approaches throw restrictions errors that this video will not play, go on youtube etc.Some approaches enters in fullscreen while entering play mode. I want youtube player in specific screen only.I have added this code and it fulfils my problem.

NSString* embedHTML = [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='%d' height='%d' src='http://www.youtube.com/embed/%@?enablejsapi=1&rel=0&playsinline=1&autoplay=1' frameborder='0'>\ </body>\ </html>", width, height, @"VIDEO_ID"]; [webView loadHTMLString:embedHTML baseURL:[NSURL URLWithString:@"http://www.youtube.com"]];

0 Answers0