lightbox.js html5视频无法播放视频。我做错了什么?

问题描述 投票:0回答:1

我正在尝试使此页面上的示例特别有效,因为我的视频文件存储在Web服务器上。

https://sachinchoolur.github.io/lightgallery.js/demos/html5-videos.html

这是我的html文件。我按照灯箱github页面上的说明进行操作,但我一定错过了一些内容,因为视频无法播放。

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="css/lightgallery.css">
<link href="css/video-js.css" rel="stylesheet">
</head>
<body>
    <!-- Hidden video div -->
    <div style="display:none;" id="video1">
        <video class="lg-video-object lg-html5 video-js vjs-default-skin" controls preload="none">
            <source src="archive/devon_rayford/20200501.tom_hanks_gone.Q_dx99JcxT8.mp4" type="video/mp4">
             Your browser does not support HTML5 video.
        </video>
    </div>
    <div style="display:none;" id="video2">
        <video class="lg-video-object lg-html5 video-js vjs-default-skin" controls preload="none">
            <source src="archive/devon_rayford/20200501.Tom_Hanks_is_really_gone.Hrx1YtkpfPY.mp4" type="video/mp4">
             Your browser does not support HTML5 video.
        </video>
    </div>

    <!-- data-src should not be provided when you use html5 videos -->
    <ul id="video-gallery">
      <li data-poster="archive/devon_rayford/thumbnails/20200501.tom_hanks_gone.Q_dx99JcxT8.jpg" data-sub-html="video caption1" data-html="#video1" >
          <img src="archive/devon_rayford/thumbnails/20200501.tom_hanks_gone.Q_dx99JcxT8.jpg" />
      </li>
      <li data-poster="archive/devon_rayford/thumbnails/20200501.Tom_Hanks_is_really_gone.Hrx1YtkpfPY.jpg" data-sub-html="video caption2" data-html="#video2" >
          <img src="archive/devon_rayford/thumbnails/20200501.Tom_Hanks_is_really_gone.Hrx1YtkpfPY.jpg" />
      </li>
    </ul>
<script src="js/jquery-3.5.0.min.js"></script>
<script src="js/lightgallery.min.js"></script>
<script src="js/video.js"></script>
<!-- Include lg-video -->
<script src="js/lg-video.min.js"></script>

<!-- Include other lightgallery plugins (Optional) -->
<script src="js/lg-thumbnail.min.js"></script>

<script>
lightGallery(document.getElementById('lightgallery')); 
lightGallery(document.getElementById('video-gallery'), 
{
    videojs: true
});

lightGallery(document.getElementById('html5-videos')); 

$('#html5-videos').lightGallery();
$('#video-gallery').lightGallery({ 
    videojs: true
});

</script>

</body>
</html> 

我做错了什么?

javascript html jquery video lightbox
1个回答
0
投票

看起来像lightgallery.min.js的缩小版,有一些未知错误。我尝试使用实际版本,并且效果很好。

window.onload = function() { lightGallery(document.getElementById('video-gallery'), { videojs: true }); }

我还没有尝试过jQuery版本。

Demo

© www.soinside.com 2019 - 2024. All rights reserved.