Remove black background from html5 video. Appears for a second
Asked Answered
C

2

8

how can I remove the black background from a html5 video? It appears for a few seconds while loading. Using CSS didn't work.

The HTML:

<div id="start-screen">
  <video id="video-element">
    <source src="video-mp4.mp4" type="video/mp4">
    <source src="video-oggtheora.ogv" type="video/ogg">
  </video> 
</div>

The CSS (not working):

#start-screen, video-element {
  background-color: #fff !important;
}

Thanks!

Caoutchouc answered 31/7, 2014 at 12:50 Comment(0)
C
11

I didn't find a working solution with CSS. But what I found was that using a very small, white (or whatever color you want) poster image does the trick. So if you have the same problem, that's how I did it. I just used a 100x100px PNG file (~ 1KB in size).

<div id="start-screen">
  <video id="video-element" poster="/images/white-poster-image.png">
    <source src="video-mp4.mp4" type="video/mp4">
    <source src="video-oggtheora.ogv" type="video/ogg">
  </video> 
</div>

Have fun!

Caoutchouc answered 31/7, 2014 at 12:50 Comment(1)
This was only an issue for me in IE. Unfortunately this did not work in IE11.Bibb
P
0

You can use a CSS class like this to remove the black bar:

[data-next-video] {
  height: unset !important;
}

I use the next-video library

Polychromy answered 6/2 at 19:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.