1

I want to create a html5 page with video and an image overlay - meaning some image that is showing over the video. This overlay will in time also be text in some cases. Is there any good way to achieve this?

What I've been trying this far is to use a <video> tag to hold the video, and draw the image into a canvas, which I place on top of the video. To show it I need to move the video back setting z-index to -1, but then the video controls won't work. Maybe there's a solution to make the controls work again, but I'm not sure if I'm on the right path here.. I am assuming there is a recommended solution to this. Maybe using a canvas which I fill both video and overlay into. Or something completely different?

Note: I edited the question as it originally pointed in the wrong direction regarding what was important here. I'd love to have a solution which makes this work seamlessly in fullscreen and everything, but the focus is: What is the appropriate way to place items on top of video - in html5?

stiank81
  • 25,418
  • 43
  • 131
  • 202

1 Answers1

7

Achieving what you want and have it supported in out-of-the-box fullscreen is problematic. Fullscreen support in html5 video is only optional and in any way not accesible thorugh the API (See discussion here). Even if you used the built in fullscreen there is no way you could inject content above it unless you are willing to change the video file itself on the server in runtime.

what you can do however (And what I did in a similar case) is to implement your own video controls, run the video tag without the built in controls, and have fun with overlaying as many layers as you want on top of your now out of focus video.

As for fullscreen, you can implement some sort of custom background fullscreen similar to what's been done here

edit: The problem you're having by placing a canvas over the video is blocking the built in html video controls. My suggestion is to implement your own video controls (play, pause, volume, seeker, etc.) using html and javascript calling the video API. You can probably even make it prettier then the ugly built in controls. Your controls can be contained in a layer above the overlaid canvas, and thus the video will be shown, above it the overlay and above it your control set.

You can read a little about implementing your own controls here or here And anyway this can easily be much better than this.

Community
  • 1
  • 1
Variant
  • 17,279
  • 4
  • 40
  • 65
  • Thx. +1 for some good points. Now that you say it - I'm aware of the fullscreen issues. So I edited the question to point out that this really isn't my main concern here. The question is really: How do I place items on top of the video? What is the appropriate way to structure this? You mention overlaying as many layers as I want. Want to elaborate how exactly I should do this? – stiank81 Jun 19 '11 at 14:09
  • edited in some more detail about my intentions. do let me knwo if you need more clarifications. – Variant Jun 19 '11 at 14:31
  • 1
    Added some more reference links – Variant Jun 19 '11 at 14:36