-
-
Save 7iomka/0a6112075bf103fe0952f1b0babb9a94 to your computer and use it in GitHub Desktop.
Modal dialog with a YouTube player
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> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
<script src="http://code.jquery.com/jquery.min.js"></script> | |
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> | |
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script> | |
</head> | |
<body> | |
<!-- Open a modal dialog button --> | |
<a href="#" data-toggle="modal" data-target=".video-dialog">How to Use Ask the Experts</a> | |
<!-- Video Player Dialog --> | |
<div class="modal fade video-dialog" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true"> | |
<div class="modal-dialog modal-lg"> | |
<div class="modal-content"> | |
<div class="modal-body"> | |
<div id="videoDialogPlayer" class="vidflex"></div> | |
</div> | |
<div class="modal-footer"> | |
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button> | |
</div> | |
</div> | |
</div> | |
</div> | |
<script> | |
(function () { | |
var el = document.createElement('script'); | |
el.src = "//www.youtube.com/iframe_api"; | |
var s = document.getElementsByTagName('script')[0]; | |
s.parentNode.insertBefore(el, s); | |
var videoDialogPlayer; | |
window.onYouTubeIframeAPIReady = function () { | |
videoDialogPlayer = new YT.Player('videoDialogPlayer', { | |
height: '390', | |
width: '640', | |
videoId: '4HG6Ek_SyJs' | |
}); | |
} | |
$(function () { | |
$('.video-dialog').on('shown.bs.modal', function () { | |
videoDialogPlayer.playVideo(); | |
}).on('hide.bs.modal', function () { | |
videoDialogPlayer.stopVideo(); | |
}); | |
}); | |
}()); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment