Last active
February 25, 2016 04:20
-
-
Save alejogutierrez/e81afe871d6593c86d63 to your computer and use it in GitHub Desktop.
Embed youtube video without console errors
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
<!doctype html> | |
<html> | |
<head> | |
<title>Embed youtube video</title> | |
<meta charset="utf-8"> | |
<link href="video.css"> | |
</head> | |
<body> | |
<div id='embed-container'> | |
<div id='ytapiplayer'></div> | |
</div> | |
<script src="https://code.jquery.com/jquery-1.11.2.min.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script> | |
<script src="video.js"></script> | |
</body> | |
</html> |
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
#embed-container { | |
height: 315px; | |
overflow: hidden; | |
position: relative; | |
width: 560px; | |
} | |
#embed-container iframe, .embed-container object, .embed-container embed { | |
height: 100%; | |
left: 0; | |
position: absolute; | |
top: 0; | |
width: 100%; | |
} |
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
(function ($, window, document) { | |
loadVideoPlayer("iYWzMvlj2RQ"); | |
function loadVideoPlayer(id) { | |
if (swfobject.hasFlashPlayerVersion("9.0.18")) { | |
var params = { allowScriptAccess: "always" }, | |
attrs = { id: "myytplayer" , autoplay: 0, wmode: 'transparent'}; | |
swfobject.embedSWF("http://www.youtube.com/v/" + id + "?enablejsapi=1&playerapiid=yplayer&version=3&autoplay=0", "ytapiplayer", "560", "315", "8", null, null, params, attrs); | |
}else{ | |
$("#embed-container").html("<iframe src='http://www.youtube.com/embed/"+ id +"' frameborder='0' allowfullscreen></iframe>"); | |
} | |
} | |
})(jQuery, window, document); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment