So far, we've concentrated on developing our basic video player, using jQuery. It's time now to change track, and take a look at another useful feature that you can use with HTML5 videos—overlays. This can help to give emphasis to displaying a video, as you can provide a mask to cover elements in the background, thereby removing some of the distraction.
For this task, you need to avail yourself of a copy of the shareware application VideoLightbox—at the time of writing, the latest version is 2.1, which is available from http://www.videolightbox.com. It is free for non-commercial use, so if you need to use it commercially, you will need to purchase a license that is $49 at the time of writing. You will also need a copy of a video in MP4 format—one of the ones you've converted, or used, from earlier will do fine.
videolightbox-setup.exe
file, accepting all of the defaults.VideoLightBox
in your Documents
folder. VideoLightbox will generate the code for you, and display the results in your default browser:<!DOCTYPE html> <html> <head> <title>VideoLightBox Test</title> <link type="text/css"rel="stylesheet" href="index_videolb/videolightbox.css" /> <link rel="stylesheet" type="text/css" href="index_videolb/overlay-minimal.css"/> <script src="http://cdn.jquerytools.org/1.2.7/full/ jquery.tools.min.js"></script> <script src="index_videolb/swfobject.js" type="text/javascript"></script> </head> <body bgcolor="#f0f0f0"> <div class="videogallery"> <a class="voverlay" href="index_videolb/player.swf?url=video/bbb400p.mp4&volume=10 0" title="bbb400p"> <img src="index_videolb/thumbnails/bbb400p.png" alt="bbb400p" /> <span></span> </a> </div> <script src="index_videolb/videolightbox.js" type="text/javascript"></script> </body> </html>
VideoLightbox uses a combination of jQuery Tools (http://www.jquerytools.org) and the SWFObject library (http://code.google.com/p/swfobject/)—the SWFObject acts as a container, into which a base player file is stored, and from within which the MP4 video is played. The jQuery Tools library is used to provide the overlay functionality. A call is made to the player "container" (in this instance player.swf
), which stores an instance of our video, and is used to provide the stop/start controls for video playback.
We've taken a look at a number of recipes, to show you how you can embed HTML5 video—using the new <video>
tag—within your pages. This is only just the start of what you can achieve using the new tag—there is a whole world out there to explore. I hope you've enjoyed working through the recipes, just as much as I have enjoyed writing this book!