admin管理员组文章数量:1323707
I want to draw things on HTML5 video. For that I am trying to place a canvas on the HTML5 video element.
But there is a problem when I place the canvas on the video element the video controls do not work. Since canvas getting all the mouseover and click events. Is there a way to delegate the events to video controls or show the controls in somewhere else?
Any help/idea would be great.
I want to draw things on HTML5 video. For that I am trying to place a canvas on the HTML5 video element.
But there is a problem when I place the canvas on the video element the video controls do not work. Since canvas getting all the mouseover and click events. Is there a way to delegate the events to video controls or show the controls in somewhere else?
Any help/idea would be great.
Share Improve this question edited Sep 22, 2011 at 8:01 pimvdb 155k80 gold badges311 silver badges356 bronze badges asked Sep 22, 2011 at 7:46 mcadircimcadirci 1861 gold badge2 silver badges12 bronze badges 1- Perhaps you want it the other way round: drawing the video on canvas and enhance it with fancy stuff and interaction there? – pimvdb Commented Sep 22, 2011 at 8:01
4 Answers
Reset to default 2What you should do is implement your own controls (or use an existing set such as videojs)
You can read my answer to this question: Html5 video overlay architecture
You can capture the click events in the canvas and calculate their position. Based on that, you could approximate which control was targeted and make the video changes your self.
I mean something like this :
canvas.onclick = function(e){
if(isOverPauseBtn(e))
video.pause();
//.. and so on
}
Increase the z-index of canvas. z-index=10
Bring the video under the canvas.
Height of canvas = height of entire video - height of video controls.
You can cover only the video part with canvas and if hover on the bottom of the canvas, you will get the controls
If you don't need the canvas to receive any pointer events, then you can use the CSS pointer-events
property on the canvas and set it to none
.
本文标签: javascriptHTML5 Placing a canvas on a video with controlsStack Overflow
版权声明:本文标题:javascript - HTML5: Placing a canvas on a video with controls - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742130855a2422151.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论