I have this code in html:
<div class="flex-video widescreen youtube">
<iframe id="ytplayer" type="text/html" width="640" height="360" src="https://www.youtube.com/embed/{{Video.v_id}}?autoplay=1&enablejsapi=1&autohide=1" frameborder="0" allowfullscreen> </iframe>
</div>
and this code in Javascript:
function onYouTubePlayerReady(playerId) {
console.log("player ready");
ytplayer = document.getElementById("ytplayer");
}
When I type in Firefox console this:
ytplayer.playVideo();
I get the not function error:
TypeError: ytplayer.playVideo is not a function
Also the console.log("player ready"); does not print at all.
Can anybody help me?
I want to controll the player with javascript api not with the IFrame api. And I want the video player to be in html5.
edit: I have the jspapi enabled (enablejsapi=1)