Is there a way to overlay a <canvas> over a fullscreen HTML5 <video>?

ぃ、小莉子 提交于 2019-11-30 18:26:45

问题


I'm using videojs to play video, and I've done some manipulation on the video content frame by frame and display it in a <canvas> (ID: 'display').

When the video is playing, <canvas> can display in front of the <video> with the following css.

<style type="text/css">
    canvas#display {
        z-index: 1;
        postion: relative;
        top: some-video-height-px;
    }

    video#videoDiv_html5_api {
        z-index: -2;
    }

    div.vjs-controls {
        z-index: 3;
    }

</style>

It seems that z-index attribute is not working when <video> enters full screen mode. It keeps in the front and <canvas> cannot overlay over <video>


In W3C Documents https://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html#ui

we have

:fullscreen {
  position:fixed;
  top:0;
  left:0;
  right:0;
  bottom:0;
  z-index:2147483647;
  box-sizing:border-box;
  margin:0;
  width:100%;
  height:100%;
}

It seems that z-index has been set to the Integer.MAX_VALUE...


回答1:


I find the answer myself. you just need to set the canvas.style.z-index to be 2147483647, then the will cover



来源:https://stackoverflow.com/questions/9461453/is-there-a-way-to-overlay-a-canvas-over-a-fullscreen-html5-video

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!