Create <video> element dynamically

This commit is contained in:
Jerome Charaoui 2014-01-27 23:02:10 -05:00
parent 1bb130d37b
commit 80060b37c1
2 changed files with 3 additions and 4 deletions

View File

@ -23,7 +23,6 @@
</div> </div>
<div id="video-box"> <div id="video-box">
<div id="video-box-inner"> <div id="video-box-inner">
<video id="video" controls></video>
</div> </div>
</div> </div>

View File

@ -147,7 +147,7 @@ $(document).ready(function() {
$("#album-view").removeClass("photo-view-container"); $("#album-view").removeClass("photo-view-container");
$("#subalbums").show(); $("#subalbums").show();
$("#photo-view").hide(); $("#photo-view").hide();
$("#video")[0].pause() $("#video").remove();
} }
setTimeout(scrollToThumb, 1); setTimeout(scrollToThumb, 1);
} }
@ -189,7 +189,7 @@ $(document).ready(function() {
$(window).unbind("resize", scaleVideo); $(window).unbind("resize", scaleVideo);
$(window).unbind("resize", scaleImage); $(window).unbind("resize", scaleImage);
videoSrc = photoFloat.videoPath(currentAlbum, currentPhoto); videoSrc = photoFloat.videoPath(currentAlbum, currentPhoto);
$("#video") $('<video/>', { id: 'video', controls: true }).appendTo('#video-box-inner')
.attr("width", width).attr("height", height).attr("ratio", currentPhoto.size[0] / currentPhoto.size[1]) .attr("width", width).attr("height", height).attr("ratio", currentPhoto.size[0] / currentPhoto.size[1])
.attr("src", videoSrc) .attr("src", videoSrc)
.attr("alt", currentPhoto.name) .attr("alt", currentPhoto.name)
@ -219,7 +219,7 @@ $(document).ready(function() {
.attr("title", currentPhoto.date) .attr("title", currentPhoto.date)
.load(scaleImage); .load(scaleImage);
$("head").append("<link rel=\"image_src\" href=\"" + photoSrc + "\" />"); $("head").append("<link rel=\"image_src\" href=\"" + photoSrc + "\" />");
$("#video")[0].pause() $("#video").remove();
$("#video-box").hide(); $("#video-box").hide();
$("#photo-box").show(); $("#photo-box").show();
} }