Created
April 18, 2013 15:35
-
-
Save ingowennemaring/5413702 to your computer and use it in GitHub Desktop.
Load a video later via jQuery (incl. fix for webkit)
This file contains hidden or 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
<video width="300" height="500" poster="poster.jpg"> | |
<source type="video/mp4" src="" data-src="video.mp4" /> | |
<source type="video/webm" src="" data-src="video.webm" /> | |
</video> |
This file contains hidden or 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
$('source[data-src]').each( | |
function(i) { | |
var $this = $(this); | |
// Webkit-Fix | |
if($.browser.webkit && $this.attr('type') == "video/mp4") { | |
$this.parent().attr('src', $this.data('src')); | |
} | |
$this.attr('src', $this.data('src')).removeAttr('data-src'); | |
$this.parent().get()[0].load(); | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment