0
votes

i need to play youtube videos in my iOS app. I am getting the YouTube video Links by youtube api.I am getting an error while playing few videos from the list the message is like this.."This Video contains content from WMG.It is restricted from playback on certain sites Watch on YouTube". Apps like McTube playing all type of YouTube videos.What are the videos are not playing in my app are playing in MCTube App. How can i play all formats of youtube videos in my app?

My code:

embedHTML12345 =[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',{videoId: '%@',playerVars: {'enablejsapi':1,'rel':0,'playsinline':1 ,'autoplay': 1, 'controls': 0,'modestbranding':1,'wmode':'transparent','color':'white','theme':'light'},events:{onReady:onPlayerReady,'onStateChange': onPlayerStateChange,onError:onPlayerError}})}function onPlayerReady(a){  a.target.playVideo(); }function onPlayerStateChange(e){if(e.data==YT.PlayerState.PAUSED){ytplayer.playVideo();}if(e.data==YT.PlayerState.ENDED){window.location=\"ios:webToNativeCall\";}}function onPlayerError(d){window.location=\"jos:webToErrorCall\";}</script><iframe id='playerId' type='text/html' width='320' height='270' src='http://www.youtube.com/embed/%@?enablejsapi=1&modestbranding=1&wmode=transparent&color=white&showinfo=0&rel=0&playsinline=1&autoplay=1&controls=0&theme=light&startSeconds=%@&endSeconds=%@' frameborder='0'></body></html>",videoId, videoId,popular.startStr,popular.endStr];

[YTV_WebView loadHTMLString:embedHTML12345 baseURL:[[NSBundle mainBundle] resourceURL]];

enter image description here

1

1 Answers

1
votes

This is neither your code's error nor YouTube's. The video is set to be played only on youtube.com and not to be embedded on external sites including UIWebView.