Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide html5 video controls on iOS 12

HTML5 video player has been showing controls only in iOS 12.x.x even when the controls are set to false in video tag but all other browsers are working fine and don't show the controls.

The scenario is that whenever page loads we autoplay the video on banner but if battery saver feature is turned on then it will not autoplay the video shows the play button with initial thumbnail (only in iOS 12.x.x) while in other browsers it shows the initial thumbnail of the video without any play button.

My code looks like this:

<video id="header-video" autoplay="true" controls="false" playsinline="true" muted="true" loop="true">
  // sources here
</video>

I am looking for the solution to hide this play icon (shown in attached image) but if that's not possible then is there any solution through which I can know that power saving mode is turned on and hide the video (because I have a background for backward compatibility).

**enter image description here**

like image 548
Mehmood Ahmad Avatar asked Oct 30 '18 18:10

Mehmood Ahmad


People also ask

How do I hide controls in HTML video?

We can hide the controls by not adding the controls attribute to the video element. Even without controls attribute on the elements the user can view the controls section by right-clicking on the video and enabling the show controls .

How do you turn off controls in HTML?

A disabled input element is unusable and un-clickable. The disabled attribute can be set to keep a user from using the <input> element until some other condition has been met (like selecting a checkbox, etc.). Then, a JavaScript could remove the disabled value, and make the <input> element usable.

How do I hide a video tag in HTML?

To hide a video on a web page, use yourVariableName. style. display='none'.


1 Answers

I know this was asked over one year ago but I wanted to share the solution for others.

What I did was, I removed the autoplay attribute from the video-element and because I still wanted it to behave as with the attribute I added following js.

const video = document.getElementById('video-input');
video.play();
like image 62
Noah V. Avatar answered Oct 06 '22 19:10

Noah V.