html
<html>
<head>
<style type="text/css"> body { background-color: transparent; color: white; }
</style>
</head>
<body style="margin:0">
<embed id="yt" src="http://www.youtube.com/v/6eK-W32IME0?fs=1&hl=en_US&enablejsapi=1" type="application/x-shockwave-flash" width="330" height="200"></embed>
</body>
</html>
The code I’m running to try to play the video is
var yt = document.getElementById("yt");
yt.playVideo();
The JS error I get is
TypeError: Object #<HTMLEmbedElement> has no method 'playVideo'
But it seems like this is how everyone else does it. What’s the deal?
** EDIT **
** EDIT **
The current JSFiddle now works fine on a pc/mac, but not on an iPad.
I think you need to add
&enablejsapi=1to the querystring of the URL referencing the video in your<embed>object.Also, try replacing your
<embed>element with an<object>element. Here’s a working example.A note about iOS/Mobile Webkit:
Apparently, according to this answer, Apple explicitly prohibits automated control of embedded media in Safari or other Mobile Webkit browsers, requiring the iOS user to interact directly with the video object to initiate playback. This goes for
objectandembedelements, as well as HTML5videoandaudioelements.