So the issue with modals/dialog and iframe videos / youtube embeds is that they keep playing in the background. This stops the playback when the dialog is closed. No More video playing in the background.
Created
October 14, 2014 00:53
-
-
Save kruxor/bd9485cc014b71b63757 to your computer and use it in GitHub Desktop.
A Pen by Luke.
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
<button id='vidopen'>Open Video Dialog</button> | |
<div id='video' title='WowCraft Episode 12 How to Quest'> | |
<iframe width="560" height="315" src="//www.youtube.com/embed/ILxX0ALpWoM?rel=0" frameborder="0" allowfullscreen></iframe> | |
</div> |
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
$('#vidopen').click(function () { | |
$('#video').dialog({ | |
width: 610, | |
height: 390, | |
draggable: true | |
}); | |
$('#video').bind('dialogclose', function(event) { | |
replace_content('#video'); | |
}); | |
return false; | |
}); | |
function replace_content(id) { | |
var video = $(id).html(); | |
$(id).html(""); | |
$(id).html(video); | |
} |
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
button { | |
padding:20px 40px; | |
} | |
#video { | |
display:none; | |
text-align:center; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment