Always show video controls

Is there a way to Always show video controls in an HTML5 tag instead of just showing them on MouseOver?

Video code:

<table cellpadding="0" cellspacing="0"> <tr> <td runat="server" width="680px" height="383px" id="vContainer"> <div style="z-index: 1;" runat="server" id="cont"> <div runat="server" style="background: rgba(200, 200, 200, 0.6) url('/images/Play.png') no-repeat center center;" id="img"> </div> <video id="player" style="z-index: 1; border: 1px solid #000000;" width="100%" height="100% " title="" controls runat="server"> <source runat="server" id="ffVideo" type="video/ogg" /> <source runat="server" id="mp4Video" type="video/mp4" /> </video> <embed id="playerOld" width="680px" height="383px" autostart="false" allowfullscreen="true" title="" style="display: none" type="application/mp4" runat="server" /> </div> </td> </tr> </table 
<P β†’
+6
source share
1 answer

November 2017 update. Please note that due to new changes in Safari 11 this no longer works in this browser. I will update the message if I find a way.

Although hidden controls are part of the HTML5 video specification. There are two ways to do this through javascript, and the other through css.

In Javascript, you can add an event handler for the timeupdate event, which changes each time the playback position changes, in other words, the event always occurs during video playback.

Assuming the identifier for the video element is called a β€œplayer,” the javascript code would look like this:

JS:

 //assign video element to variable vid var vid = document.getElementById("player"); function videoTimeUpdate(e) { //set controls settings to controls,this make controls show everytime this event is triggered vid.setAttribute("controls","controls"); } //add event listener to video for timeupdate event vid.addEventListener('timeupdate', videoTimeUpdate, false); 

A working example above is given here: https://jsfiddle.net/l33tstealth/t082bjnf/6/

The second way to do this is through CSS, but this will only work for website-based browsers, therefore it is limited. You can make the control panel always show.

CSS for this would look like this:

CSS

 video::-webkit-media-controls-panel { display: flex !important; opacity: 1 !important; } 

Working sample (works only in web set-based browsers): https://jsfiddle.net/l33tstealth/t082bjnf/7/

+8
source

All Articles