简体   繁体   English

HTML5 视频:如何用海报覆盖控制器

[英]HTML5 Video: How to Cover Controllers with a poster

I am using HTML5 to load a video from the backend.我正在使用 HTML5 从后端加载视频。 The UX requires a cover image that covers the whole HTML5 video player, including the controller.用户体验需要覆盖整个 HTML5 视频播放器的封面图片,包括控制器。 The issue is when I use the poster attribute to load a cover image, it does not cover the controller.问题是当我使用海报属性加载封面图像时,它没有覆盖控制器。 Like their z-index is higher than the poster.就像他们的 z-index 高于海报一样。 Please see image below:请看下图:

在此处输入图片说明

How can I have the poster image cover the controllers as well?我怎样才能让海报图像也覆盖控制器?

Here is one simple solution.这是一个简单的解决方案。

1) Remove controls attribute from video element 1) 从视频元素中删除控件属性

2) Show controls when video is clicked, like onclick="this.controls = true" or in event listener, eg 2)点击视频时显示控件,如onclick="this.controls = true"或在事件侦听器中,例如

var video = document.getElementById('video');
video.addEventListener('click', function(){
    video.controls = true;
}, false);

3) If you don't want to show controls when video is not loaded yet, you can check its readyState https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/readyState 3)如果您不想在视频尚未加载时显示控件,您可以检查其readyState https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/readyState

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM