Created
July 31, 2014 07:04
-
-
Save rayflores/3c9fa0c3d228716bec12 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // start ?> | |
<div class="ytwrapper"> <!-- wrapper --> | |
<a href="javascript:void(0)" onMouseOver="play()"> | |
<div id="player"></div><?php // where video will be housed ?> | |
</a> | |
<script> // 2. This code loads the IFrame Player API code asynchronously. | |
var tag = document.createElement('script'); | |
tag.src = "http://www.youtube.com/player_api"; | |
var firstScriptTag = document.getElementsByTagName('script')[0]; | |
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); | |
// 3. This function creates an <iframe> (and YouTube player) | |
// after the API code downloads. | |
var player; | |
function onYouTubePlayerAPIReady() { | |
player = new YT.Player('player', { | |
playerVars: { 'autoplay': 1, 'controls': 1,'autohide':1,'wmode':'opaque' }, | |
videoId: 'zgGAvHl1Aks', | |
height: '495', | |
width: '880', | |
events: { | |
'onReady': onPlayerReady} | |
}); | |
} | |
// 4. The API will call this function when the video player is ready. | |
function onPlayerReady(event) { | |
event.target.mute(); | |
} | |
function play() { // function for onMouseOver :) | |
if (player) { | |
player.unMute(); | |
} | |
} | |
</script> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment