I’ve got a youtube video that renders ok using object embed, in all browsers except ipad, here’s the code:
<object id="ytViewer" width="468" height="327" type="application/x-shockwave-flash" data="http://www.youtube.com/apiplayer?version=3&enablejsapi=1&version=3&playerapiid=ytViewer" state="0" mute="0">
<param name="allowScriptAccess" value="always">
<param name="autoplay" value="0">
<param name="WMode" value="Opaque">
</object>
I’m using object embed, as I’ve made some custom player controls in javascript, which don’t work when I use an iframe to embed the video.
It uses some javascript to pull the video in, but is it because ipad does’nt support flash embed?
Update:
function loadPlayer( divToLoad, plId, vidid) {
var params = {
allowScriptAccess: "always",
autoplay: 0
};
var atts = {
id: plId
};
// All of the magic handled by SWFObject (http://code.google.com/p/swfobject/)
swfobject.embedSWF("http://www.youtube.com/apiplayer?" + "&enablejsapi=1&version=3&playerapiid=" + plId, divToLoad, "468", "327", "9", null, null, params, atts);
swfobject.createCSS("#" + plId, "display:block");
$('#' + plId + '_container').attr('videoid', vidid);
}
So I need to get the function above to add the embed tag, not sure how to do that.
Thanks
Your code only links to the YT flash video player (not even pointing to a video).
Why not just use the automatically generated “share” code of YouTube?
Look out for the “embed” button in the “share” section right below your video and copy the default code. You can even activate some additional options:
This should work for all browsers.
Edit:
if you need the object/param syntax, you can switch to the “old” way of embedding videos: the (currently fourth) option can be ticked to use this deprecated code:
Test it with this music video from Psy:
http://www.youtube.com/watch?v=KVHO-FWuMXs