I found many questions in this forum regarding embedding youtube video and autoplay, but none of them cleared all my doubts.
I found two methods to embed youtube vid
You can also use this trick from the Saurabh Wadhwa Answer that fire the endActionsForControlEvents:UIControlEventTouchUpInside
after UIWebView finished download
Q. If I am correct that (2) is recommended
A. Yes (2) method is for i-devices where no flash support.
Q. Autoplay with (2) is not possible.
A. No autoplay is not possible as of now.
Update: I am able to autoplay youtube video by using Youtube JS APIs see https://developers.google.com/youtube/js_api_reference
Just call playVideo from onPlayerReady
function onPlayerReady(event) {
event.target.playVideo();
}
Autoplay is possible by issuing:
webView.mediaPlaybackRequiresUserAction=FALSE;
I solved the problem by adding the follow code:
webview.mediaPlaybackRequiresUserAction=NO;
webview.allowsInlineMediaPlayback=YES;