HTML5 video in jQuery colorbox -
in need display local video in html5 in lightbox.
i've tried several method various results
1 - iframe
the simplest solution , best one, one.
<a class="lightboxed" href="media/vid1.mp4">vid1</a> <script> jquery('a.lightboxed').colorbox({iframe:true, width:"80%", height:"80%"}); </script>
but when this, i've got 2 white stripe left , right video (up , down on mobile screen). wan't lightbox fit percentage on 1 dimension , fit width (or height) of video, images. seems iframe doesn't have width or height. i'll fine if turn background color black, don't know how do.
2 - inline
<div style="display:none" id="vid"> <video autoplay width="80%"> <source src="media/vid1.mp4 type="video/mp4"> </video> </div> <a class="lightboxed" href="#vid">vid1</a> <script> jquery('a.lightboxed').colorbox({inline:true); </script>
which worse previous version. white background still there, content isn't center , video isn't @ size.
so question :
is there better way achieve lightboxed video ? did misunderstand something, or did i've done wrong ?
you can set background color via css:
#cboxoverlay { display: table; height: 100%; position: fixed; top: 0; width: 100%; background: #000; z-index: 9999; }
to fit iframe video use colorbox options:
$('a.colorbox-video').colorbox({ transition: 'fade', rel:'gal', width: '80%', height: '80%', fixed: true, iframe: true, onload: function() { $('#cboxclose').addclass('btn btn-sm btn-link').css('color','white'); }, oncomplete: function() { $('#cboxloadedcontent iframe').addclass('iframe-loaded'); } });
where css rules are:
.iframe-loaded { width:100%; height:98%; }
Comments
Post a Comment