我正在尝试让此页面上的示例专门工作,因为我的视频文件存储在我的网络服务器上。
https://sachinchoolur.github.io/lightgallery.js/demos/html5-videos.html
这是我的 html 文件。我按照 lightbox 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>
我做错了什么?
最佳答案
看起来 lightgallery.min.js 的缩小版本有一些未知错误。我尝试使用真实版本,效果很好。
<script src="https://cdn.jsdelivr.net/npm/lightgallery.js@1.1.3/dist/js/lightgallery.js"></script>
<script src="https://cdn.rawgit.com/sachinchoolur/lg-video.js/master/dist/lg-video.js"></script>
我还没有尝试过 jQuery 版本。
关于javascript - lightbox.js html5 视频不播放视频。我做错了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61575314/