I'm working with the JS API for YouTube and for displaying the video player, use of embedSWF is recommended by Google in the documentation, like this:
<script type="text/javascript" src="swfobject.js"></script>
<div id="ytapiplayer">
You need Flash player 8+ and JavaScript enabled to view this video.
</div>
<script type="text/javascript">
var params = { allowScriptAccess: "always" };
var atts = { id: "myytplayer" };
swfobject.embedSWF("http://www.youtube.com/v/VIDEO_ID?enablejsapi=1&playerapiid=ytplayer&version=3","ytapiplayer", "425", "356", "8", null, null, params, atts);
</script>
While this works fine on my computer and Android devices, on iOS the ytapiplayer div does not turn into an embedded player but instead just displays its original contents, i.e. the error message saying Flash player 8+ and JS are required.
Is it possible to get my this working on iOS? If so, how?
Thanks in advance!
I did this exact thing a few months ago for a project...
Javascript, very similar to what you have:
What swfobject.js is going to do is look for an HTML div named "youTubeDiv" and replace all of it's contents with an SWF youtube player
(i did this b/c the iframe solution had z-index issues with an HTML5 project i was working on)
Now the HTML:
Maybe you should try new YouTube iframe Player API? https://developers.google.com/youtube/iframe_api_reference
It works with mobile devices without thinking about Flash. Embedding example: