Firefox全屏视频附加DOM元素

时间:2017-08-21 13:20:28

标签: firefox html5-video z-index html5-fullscreen

无论我如何将DOM中的元素作为html5视频上的叠加(静态或动态),Firefox中的这些元素都不可见,尽管z-index设置为2147483647,不透明度1和显示块。

请参阅2个类似的答案,在Chrome中工作,但不在FF中:

Overlay on HTML5 Fullscreen Video

Displaying elements other than fullscreen element (HTML5 fullscreen API)

1 个答案:

答案 0 :(得分:8)

要显示叠加元素,而不是将视频设为全屏,请将视频元素全屏设为全屏。

请参阅此处示例 - https://jsfiddle.net/tv1981/tm069z9c/1/

在以下结构中,我正在制作'容器'全屏

<div id="container">
  <div class="btn-fs" id="btnFS">
    Fullscreen
  </div>
  <div class='logo'>
    Logo Overlay
  </div>
  <video width="100%" height="100%" autoplay>
    <source src="http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4" type="video/mp4"> Your browser does not support the video tag.
  </video>
  <div class='footer'>
    This is Test Overlay for Video
  </div>
</div>

的JavaScript

fs.addEventListener('click', goFullScreen);

function goFullScreen() {
  var fullscreenElement = document.fullscreenElement || document.mozFullScreenElement ||
    document.webkitFullscreenElement || document.msFullscreenElement;
  if (fullscreenElement) {
    exitFullscreen();
  } else {
    launchIntoFullscreen(document.getElementById('container'));
  }
}

这适用于Chrome版本60.0.3112.101(官方版本)(64位),FireFox开发人员版56.0b5(64位)