简体   繁体   中英

HTML5 Video: How to Cover Controllers with a poster

I am using HTML5 to load a video from the backend. The UX requires a cover image that covers the whole HTML5 video player, including the controller. 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. 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

2) Show controls when video is clicked, like onclick="this.controls = true" or in event listener, eg

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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