Comic Director - Deliver Videos Easier with the HTML5 Video Element

Anyone browsing the web or using web-based applications today will know that you can embed video on a web page or within an app. Less known are the recent revisions to the HTML5 specification that have brought us closer to developing a standard way to easily embed video on the web. The HTML5 <video> element helps you deliver and embed video content on the web and in applications with less reliance on third-party plugins like Flash and QuickTime as well as reduce the need for JavaScript-based players. While still evolving, the HTML5 <video> element supports many modern video formats and codecs, but not yet all browsers. Luckily, there are many alternatives and backup options you can use to make sure your video content gets delivered to as many users as possible.

Video with Third-Party PluginsVideo on the web has almost always been delivered using third-party plugins like Flash or with JavaScript video players. While reliable in most cases, there are still problems that can occur. The code itself is typically much longer and more complicated when using Flash or JavaScript, and playback performance can vary from system to system. Many mobile devices currently do not support Flash video, which prevents viewers from watching video content.

The code sample below demonstrates a Flash-based approach to embedding video into a web page or HTML5-based application. The code is longer and lacks clear descriptive code language and video playback performance can vary depending on platform and implementation.

Containers and CodecsWith the HTML5 <video> element, there are three main video formats currently supported: MP4, WebM, and Ogg. Some browsers only support one of these three formats, so you may want to include all three file types of a single video asset in order to ensure the largest number of users can view your content.

There are several properties you’ll want to know about when working with the <video> element in your HTML5 applications. The “poster” property lets you choose the image that appears in the window before the user presses play. The “controls” property tells the browser to render playback controls. The “src” property is where you designate the video content that is available to display. Again, different browsers support different video types so you’ll need to reference multiple video files, one for each supported format. You can include a Flash backup option for older browsers that do not support HTML5 video playback, but unless you are trying to support Internet Explorer 8 or older browsers, it’s not worth the effort. Instead you can put a message inside the video tag informing users with old browsers that they need to upgrade their browser to watch the video.

Build a Custom UI for HTML5 Video PlayersThe default look of an HTML5 video player object is browser dependent; however, it is possible to scale, rotate, resize and re-skin the video player using standard JavaScript and CSS techniques. Below we will re-skin the video controls with our own design.

Custom player control UI with CSS and JavaScript

First, you need to hide the existing video controls by removing the “control” property of the <video> element. Then you can add new button controls and style them using CSS. And to finish it off, use JavaScript to make your video button controls work.

The HTML5 <video> element is easy to use and more flexible than using Flash videos (which won’t run on many mobile devices). The <video> tag is still evolving—be sure to double-check what is and isn’t supported by your target browsers and devices. Future advancements of the HTML specification could lead to more <video> tag capabilities like full screen view and access to peripherals like cameras and microphones. One thing is certain: the <video> tag is quickly becoming the best way to integrate video on the web and web applications.

Learn more about web application development at the Intel Developer Zone. Check out the new HTML5 Development Environment and look at code examples at the HTML5 Playground.

Intel HTML5 Development Environment:The XDK is the world’s first HTML5 powered mobile application development tool. With it, you can create, debug and build customized, robust HTML5 apps in hours, and the XDK runs on either Mac or PC Platforms. Build hybrid HTML5 apps for iOS, Android, Windows 8 and Tizen tablets and smartphones, as well as HTML5 web apps for Facebook, Google and other hosting platforms.software.intel.com/html5tools

Intel HTML5 Playground:The HTML5* Playground provides developers with a web based code editor, a live application preview window, and a library of sample code and snippets to use as starting points. Anything you that you create, can be shared using a permalink.software.intel.com/appup/html5-playground