75

I want to hide the big play button that appears by default on the <video> element

Is it possible?

ilyo
  • 35,851
  • 46
  • 106
  • 159
  • I don't think this is possible, i may be wrong as i'm not a web developer, just iOS. However i think that is the way safari see it. If the content can be played the circle appears, content then can't play a cross through or just won't appear. – Alex Trott Jan 18 '12 at 19:45

16 Answers16

109

I don't have any iOS device handy to test, but perhaps try this:

video::-webkit-media-controls {
    display:none !important;
}
Ian Devlin
  • 18,534
  • 6
  • 55
  • 73
73

It seems Apple has changed the shadow-dom again.

In order to hide the play button control you must use the following CSS:

/* This used to work for the parent element of button divs */
/* But it does not work with newer browsers, the below doesn't hide the play button parent div */

*::-webkit-media-controls-panel {
  display: none!important;
  -webkit-appearance: none;
}

/* Old shadow dom for play button */

*::-webkit-media-controls-play-button {
  display: none!important;
  -webkit-appearance: none;
}

/* New shadow dom for play button */

/* This one works! */

*::-webkit-media-controls-start-playback-button {
  display: none!important;
  -webkit-appearance: none;
}
Daemeron
  • 856
  • 8
  • 9
  • 1
    Confirmed that this also clears the android play too for S6 and up. – Huginn Nov 08 '16 at 14:02
  • @Skadi2k3 That would mean that iOS7 have different shadow-dom elements then described above, unfortunately I do not have access to browserstack for now to emulate iOS7 and find the right elements to hide. If you do you could find them by inspecting and adjust those css rules accordingly... – Daemeron Nov 30 '16 at 16:45
  • Did anybody ever find the right elements to hide for iOS 7? – Keab42 Jul 20 '17 at 09:58
  • It seems that Browserstack does not have native iOS7 testing option (This means you cannot open developer tools). For those with this problem the only way to find right shadow-dom is to get physical device, connect it in debugging mode and inspect... I do not have one so I cannot really help with that sorry... – Daemeron Sep 13 '17 at 10:21
  • @Daemeron , are you sure about "--webkit"? two hyphens? – crcerror Sep 28 '17 at 01:39
  • I had to add `video::-webkit-media-controls-enclosure` too – VinceOPS Oct 20 '17 at 13:38
  • @VinceOPS This is for native html5 video controls right? It would most certainly hide much more than play button. – Daemeron Oct 20 '17 at 14:11
  • @Daemeron I guess you're right. I had to do it on Android in order to hide everything on the video element. It might help someone. But you're right, it's worth mentioning it – VinceOPS Oct 20 '17 at 14:18
  • @VinceOPS Just wanted to clarify it. Yes it could be really useful for someone that wants to get rid of all controls. – Daemeron Oct 21 '17 at 22:22
  • 7
    Nothing of this works in Safari 11.0.1. While in Chrome everything is ok. Does anybody know whether it's still possible? – jeron-diovis Jan 31 '18 at 20:00
  • is this available in Android WebView ? – Najib.Nj Jul 08 '19 at 13:34
59

A look at the shadow DOM in Safari iOS tells me that what you want (hidding only the big central play button) is:

video::-webkit-media-controls-start-playback-button {
  display: none !important;
}

The answer from Ian hides everything including text tracks (closed captions ...)

Arnaud Leyder
  • 6,674
  • 5
  • 31
  • 43
  • 2
    This worked for me in iOS 9 and specifically addresses the original poster's issue. – benjarwar Sep 24 '15 at 20:17
  • 1
    For me on 9.3.1 it didn't need the `appearance` and the `!important`, just `display: none` – fregante Apr 04 '16 at 11:09
  • I think I read somewhere it is better to add the !important when tuning shadow DOM elements as 3rd party or built in libs may overwrite what is set in your CSS. The appearance CSS can probably be safely ignored for newer iOS versions. – Arnaud Leyder Apr 04 '16 at 12:43
  • I had actually implemented Ian's fix for the large circle play button before, but it seems now that it no longer works. This solution however, does work to remove the circular play button on videos for mobile Safari. – MLK.DEV May 20 '16 at 18:06
  • 1
    Does not work on iOS 14 or 15 :( – Neal Soni Oct 21 '21 at 22:03
  • @NealSoni did you find a solution for ios 14 and 15? **Edit**: never mind I just saw your answer. – Uche Ozoemena Feb 12 '22 at 18:35
40

Newer iOS versions display such play button when the device is in "Low power mode".

Kamen Stoykov
  • 1,715
  • 3
  • 17
  • 31
  • 9
    You just spared me 9000 hours of investigating this behavior <3 – Kfir Eichenblat Jul 04 '21 at 15:13
  • If I could, I would upvote this 1,000 times. I had no idea that turning on low power mode was what turned the play button back on, and I would have likely also spent far too many hours poring over my code in an attempt to find the nonexistent error. – Joseph Cheek May 04 '23 at 06:34
  • Thanks a lot! Its been challenge to understand issue, You save a lot of time ! Thanks! – Alexandr Sargsyan May 23 '23 at 15:15
8

In the video source file you can simply change

controls= "false"

For the Safari CSS, which the native browser on ios, you can also try this hacky trick

.custom-video-controls {
  z-index: 2147483647;
}

Here's a link to a details discussion on managing/hiding controls on HTML 5 video

http://css-tricks.com/custom-controls-in-html5-video-full-screen/

7

UPDATE OCTOBER 2021

All answers are outdated for iOS 13, 14, and 15. It appears because iOS low power mode prevents autoplay on all videos in the browser by default (to save power).

The best way to remove the annoying play button is to remove the autoplay tag on any video element and start playing the video when there is any user interaction.

React example below:

 <video ref={playerRef} playsInline >
let playVideo = (event) => {
   if (playerRef.current) {
      playerRef.current.play()
   }
}

Sidenote: the play button is hidden in a shadow dom that I am unable to figure out how to hide with external CSS modifications or even JS. If anyone has any ideas on how to hide a shadow dom element then that would be a better solution.

Neal Soni
  • 556
  • 1
  • 5
  • 13
  • I've tried this approach but Safari gives me this error Unhandled Promise Rejection: NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission. – rustycode Mar 07 '22 at 20:30
4

As of 20 Oct 2022,

My solution was to remove autoplay from the video element and use HTMLMediaElement.play() on page load. The promise returned from play() will catch any issues with playing the video, else the video will play as usual. My implementation in React looks like this:

useEffect(() => {
  ref &&
    ref.current
      .play()
      .then(() => {})
      .catch((err) => {
        // Video couldn't play, low power play button showing.
      });   
}, []);

This should be a relief from having to deal with the inconsistent Shadow DOM properties.

Resources:

https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/play

2

Based on Ian's answer

video::-webkit-media-controls {
    opacity: 0;
}

This will hide all controls. Good for background videos that won't autoplay.

Chloe
  • 25,162
  • 40
  • 190
  • 357
2

Today @2017 in iOS 10 this works:

.video-background::-webkit-media-controls-panel,
.video-background::-webkit-media-controls-start-playback-button {
    display: none !important;
}
Bruno
  • 6,623
  • 5
  • 41
  • 47
1

For webapps. Works iOS 10.3 iPhone7 & Safari 10.1 on Mac as well. Thx to previous contributors. I had also the issue that the element does not contain any "control" attribute at all.

'<style type="text/css">'+
    '*::-webkit-media-controls-panel {'+
     '   display: none!important;'+
      '  -webkit-appearance: none;'+
   ' }'+
    /* Old shadow dom for play button */
    '*::--webkit-media-controls-play-button {'+
        'display: none!important;'+
        '-webkit-appearance: none;'+
    '}'+
    /* New shadow dom for play button */
    /* This one works */
    '*::-webkit-media-controls-start-playback-button {'+
        'display: none!important;'+
       ' -webkit-appearance: none;'+
        '}'+
    +'</style>'
Zebra Pogo
  • 11
  • 2
1

Try this:

video {
    &::-webkit-media-controls {
        display:none !important;
    }

    &::-webkit-media-controls-start-playback-button {
        display: none!important;
        -webkit-appearance: none;
    }
}
Arpit
  • 63
  • 1
  • 8
1

Update:

IOS 13.*

  video::slotted::-webkit-media-controls-container{
      display:none !important;
      visibility: hidden!important;
      opacity: 0 !important;
     -webkit-appearance: none !important;
    }


IOS 14 changed selector to

:host::shadow::-webkit-media-controls-container{/* hide the element */}

helpful resource: html5rocks shadow dom 201

Ahmed Shehab
  • 1,657
  • 15
  • 24
  • I tried this, but it seems that it's not working, and also you have small typo in hidden; !important – Lukáš Irsák Oct 26 '20 at 12:25
  • 1
    Thanks Lukas, this is ever changing DOM layout specially with IOS Safari, please post your update if you figured it out. – Ahmed Shehab Dec 28 '20 at 13:05
  • @lukas, try to inline it, ( put it in – Ahmed Shehab Dec 30 '20 at 19:13
  • @AhmedShehab does this still work for you? These fixes aren't working for me sadly. iPhone 6 running ios 12 in real life, and I've tested iPhones up to 13 running up to ios 15 using browserstack. – Uche Ozoemena Feb 12 '22 at 19:25
  • @UcheOzoemena this dirty hack has not been tested after IOS 13, it is not advisable to do so, feel free to create your video display container and have all the perks you are looking for, especially apple ever updating DOM elements priority. btw the place of the css matter in this case. read more in the previous link! – Ahmed Shehab Feb 12 '22 at 20:00
  • Thanks, yeah I read the link and tried the different combinations but I couldn't get it to work. Can you please take a look at [this codepen](https://codepen.io/OzCodes/pen/BamdazP) and let me know if there are any changes you would make to it? – Uche Ozoemena Feb 14 '22 at 07:38
  • @UcheOzoemena you have to remember one thing about the shadow DOM, I am talking now about iphones specially on Safari, once a new video stream is initiated, the browser engine inserts the container with all the either inlined or|and the browser css, this code pen is not reproducing the conditions, a piece of advice do what you want to accomplish while debugging it manually on live iphone connected through a cable on Mac Safari debugging and 98%. you will get it right, but keep on mind you are going to do so almost with every IOS update! – Ahmed Shehab Feb 15 '22 at 08:22
  • Oh wow okay thanks! I don't have a macbook to connect a real device so that's why I was using browserstack. – Uche Ozoemena Feb 16 '22 at 08:21
0

You can't remove the play button. This video placeholder always appears as the doc says : iPhone Video PlaceHolder. But maybe you can detect you're on an iphone and display an image with a link to your video instead of the video tag.

<a href="yourvideo.mp4"><img src="yourposter.png"/></a>

The video will be launched in a player just as a video tag.

vincentp
  • 233
  • 4
  • 17
  • Remove it? No. We are just hiding it. In case someone would not mind a link to video this is ok. I struggled with this issue as I needed to have a video ready to play in the background of webpage with custom play button. – Daemeron Sep 05 '16 at 07:44
0

According to this answer, in Google Chrome we can hide the big play button like this:

    video::-webkit-media-controls-overlay-play-button {
      display: none;
    }

That might be useful if you want to hide it on Android as well as on iOS.

joeytwiddle
  • 29,306
  • 13
  • 121
  • 110
-2
video::-webkit-media-controls { display:none !important; }

Didn't work for me on iOS, but

*::-webkit-media-controls-panel {
  display: none!important;
 -webkit-appearance: none;
}

/* Old shadow dom for play button */

*::--webkit-media-controls-play-button {
  display: none!important;
  -webkit-appearance: none;
}

/* New shadow dom for play button */

/* This one works */

*::-webkit-media-controls-start-playback-button {
  display: none!important;
  -webkit-appearance: none;
}

Worked perfect!

iamwill
  • 1
  • 2
-5

Yes you can do this! The trick is to "hide" the video controls, by not adding the "controls" attribute to your video tag. Then you let it be dynamically added a few seconds after the video starts to play, by appending the "controls" property to the tag using Javascript. Simply set the value to "controls" and it will dynamically appear in the DOM... as if you had added the controls to your video tag's HTML. Adjust the timer as needed.

<video id="some-video-id" src="some-video-url" poster="some-thumbnail-url" />

<a href="javascript:void(0);" id="startVideoLink">Start the Video</a>

<script type="text/javascript">
    var oVideoTag = document.getElementById('some-video-id');
    var oLink = document.getElementById('startVideoLink');
    if (oLink && oVideoTag) {
        oLink.addEventListener('click',function(e) {
            oVideoTag.play();
            setTimeout(function() {
                oVideoTag.controls = 'controls';
            },2500);
        },false);
    }
</script>