How to Create Interactive HTML5 Video
Slowly but surely, HTML5 browsers have come to enable rich video experiences. In this article, you’ll learn how to go beyond basic video playback by adding playlists, chapter markers, poster frames, scrub bar thumbnails, and more.
Today, most web-based video is delivered in basic “press play” experiences; viewer controls tend to be limited to a play/pause button, a seek bar, and possibly a volume control.
If you just use the
Thankfully, you don’t need to break the bank to turn a basic HTML5 video player into an enhanced playback experience that can meet your viewers’ expectations.
In the January/February issue of Streaming Media, I reviewed five off-the-shelf HTML5 video players. While most of those players can be adapted with custom HTML, JavaScript, and CSS to accommodate all of the features discussed in this article, I picked JW Player 6 as the standard by which enhanced interactivity can be applied without requiring too much billable time from a web developer. (You can find more information and examples related to my last article and this article at videorx.com/players.)
Limitations of Mobile Browsers
The No. 1 factor to keep in mind with any HTML5 video experience is that mobile browsers, by and large, will not permit any customization while viewing in fullscreen mode. When playing video in fullscreen, both smartphone and tablet screens usually play browser-based video with the native video playback “chrome” specific to the operating system or browser.
Further, on many smartphones, video will only play in fullscreen mode, with native chrome -- on these platforms, there is no way to playback video inline, inside of a webpage. (Inline playback is defined as playback within the web page region where the video is initialized.)
In one sense, this built-in functionality renders all browser-based video playback equal, from your content to your competitor’s content. However, this negates the possibility of implementing any custom functionality in fullscreen mode. The only way around this current limitation is to build a native application for mobile deployment -- but at the cost of building the software and deploying it to an app store.
Mobile browsers on tablets generally permit inline video playback with customized player interfaces and overlays, as do some newer Android browsers. For example, if you want to display a graphic on top of your video, the iPad’s Safari Mobile browser will display the overlay while you’re watching the video on the page. However, if you view the video in full screen mode, the browser will remove the overlay.
Enhancement #1: Poster Frames
Many videos on the web do not include a simple poster frame, or a still image from the video clip, to indicate to the viewer the nature of the content. HTML5’s
An example of a simple poster frame, something lacking from most web videos but easily delivered via an HTML5 player.
Typical formats for poster images include JPEG and PNG, although you can also use a GIF or SVG. The default behavior of the poster frame is consistent across all browsers in that the image is displayed on initial page load. When the user clicks the play button, the poster frame disappears and the video begins to play.
If your preferred approach to implement a video player is the use of a static
Off-the-shelf web video players will differ in their JavaScript APIs for specifying a poster frame. JW Player 6 refers to the poster frame as an image property in the initial setup call:
jwplayer(“player”).setup({
image: “http://example.com/poster.jpg”,
file: “http://example.com/video.mp4”,
width: 640,
height: 360
});
Poster frames can also improve your video’s metadata for search engines. For this reason, regardless of your approach of inserting a video player on a web page, I recommend including a static