问题描述
我的 video.js 控件没有显示在视频中,而是显示在视频之外,有很多不必要的选项,如下面的屏幕截图所示。
我的代码是这样的:
{% block content%}
<style>
#video-js {
max-width:auto;
width:auto;
max-height:auto;
height:auto;
margin:auto;
padding:auto;
background-color: #343A40;
}
</style>
<video
id="video-js"
class="video-js vjs-custom-skin"
controls
preload="auto"
width=""
height=""
data-setup=""
autoplay
>
<source src="http://url.m3u8" type="application/x-mpegURL" />
<source src="http://url.flv" type="video/x-flv" />
<p class="vjs-no-js">
To view this video please enable JavaScript,and consider upgrading to a
web browser that
<a href="https://videojs.com/html5-video-support/" target="_blank"
>supports HTML5 video</a
>
</p>
</video>
<br>
<br>
<script src="https://vjs.zencdn.net/7.10.2/video.min.js"></script>
<script src="https://unpkg.com/browse/@videojs/http-streaming@2.6.0/dist/videojs-http-streaming.js"></script>
{% endblock %}
如何才能让这些奇怪的控件消失,而让视频控件(如播放、暂停、静音、音量增大/减小)正常。
解决方法
您需要添加 Video.js 样式,https://vjs.zencdn.net/7.10.2/video-js.css
另外,虽然这不是问题的原因,但包含 http-streamimg 是多余的。它包含在 Video.js 7+ 中。
,添加上面提到的 Video.js 样式后,您 然后应该能够消除、重新安排控件和调整颜色, 通过添加这样的行:
<!-- Change ordering "current-time / duration" to appear on control-bar: -->
<!-- See: https://github.com/videojs/video.js/issues/2507 -->
<style>
.video-js .vjs-current-time { display: block; }
.video-js .vjs-time-divider { display: block; }
.video-js .vjs-duration { display: block; }
.video-js .vjs-remaining-time { display: none; }
.video-js .vjs-load-progress{display: inline-block; background: PaleGreen; height: 8px; width:100%; }
.video-js .vjs-play-progress{display: inline-block; background: LightCoral; height: 8px; width:100%;}
.video-js .vjs-picture-in-picture-control { display: none; }
# (These with leading "#" sign are 'commented-out'...are present here just so the NAMES of various entities are avail for experimenting.)
#.video-js .vjs-progress-holder { margin-left: 0px; margin-right: 0px; background: Blue; }
#.video-js .vjs-loading-spinner{display: block;}
#.video-js .vjs-progress-holder .vjs-play-progress { display: none; }
</style>
Hope these help...