I am trying to load YouTube player using IFrame api.
DOM Structure
<div id="player-wrapper">
<div id="player">
</div>
</div>
Jquery code to load player
$(document).ready(function () {
$('head').append($('<script src="https://www.youtube.com/iframe_api"></script>'));
});
window.onYouTubeIframeAPIReady = function() {
Player = new YT.Player('player', {
videoId: 'RVRlV53TjzY',
playerVars : {
theme : 'light',
color : 'red',
iv_load_policy : 3,
modestbranding: 1,
disablekb: 1,
showinfo: 0,
controls: 0,
autoplay: 1,
fs:0
}
});
};
With this structure, YouTube player loads in div with id as 'player'. Along with loading YouTube player, I want to bind mousemove event on player-wrapper. On mousemove of this container, I want to show some message to user over the YouTube player.
I am trying to do this with:
$("#player-wrapper").bind('mousemove', function() {
console.log("You are viewing YouTube Video ");
});
I see that, when YouTube player is loaded, I do not get this mousemove event on player-wrapper. I tried replacing YouTube player with normal HTML5 video tag. With this I started getting mousemove event. Also looked into z-index property of these elements, but couldn't figure out what is happening.
Please help.
Thanks.