Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5: Placing a canvas on a video with controls

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.

like image 488
mcadirci Avatar asked Sep 22 '11 07:09

mcadirci


2 Answers

What 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

like image 77
Variant Avatar answered Sep 28 '22 11:09

Variant


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
}
like image 40
gion_13 Avatar answered Sep 28 '22 11:09

gion_13