100%

HTML5 Video

R Proffitt
by Richard Proffitt
iopan design

HTML5 video is a reletively new option for providing audio-visual media to the web. In the old days it was much more common to have a 3rd-party plug-in when showing videos, such as the Flash player. Embedding media files could sometimes become a complicated task. With the HTML5 <video> element we have a specific and standard way to embed a video in to a web page.

The markup is quite easy to follow, but there is a little bit of preperation to do. Yes, first of all you must prepare your content in two or three formats, so you'll need to download some good video editing software or perhaps use an online file converter. I am fond of using Freemake's “Video Converter”. There is a free version available, but the Primium version won't break the bank. There is an option with the Freemake Video Converter that allows you to process all three HTML5 formats at once.

You can take a look at the following article if you need to get hold of a video converter tool:

Free HTML5 Video Conversion Solutions

Three file types compatable with HTML5 video
Attatch Multiple Media Files

It's best to source two, or even three different file formats so as to give the browsers a choice of their prefered type. Commonly, the following three formats are chosen: .mp4, .webm and .ogv.

HTML5 Video Elements

Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Cras tellus enim, sagittis aer varius faucibus, molestie in dolor. Mauris molliadipisg elit, in vulputate est volutpat vitae.

Cras tellus enim, sagittis aer varius faucibus, molestie in dolor. Mauris molliadipisg elit, in vulputate est volutpat vitae. Pellentesque convallis nisl sit amet lacus luctus vel consequat ligula suscipit. Aliquam et metus sed tortor eleifend pretium non id urna. Fusce in augue leo, sed cursus nisl. Nullam vel tellus massa. Vivamus porttitor rutrum libero ac mattis. Aliquam congue malesuada mauris vitae dignissim.

img

<video> Attributes

Displaying Controls using the controls Attribute

Cras tellus enim, sagittis aer varius faucibus, molestie in dolor. Mauris molliadipisg elit, in vulputate est volutpat vitae. Pellentesque convallis nisl sit amet lacus luctus vel consequat ligula suscipit. Aliquam et metus sed tortor eleifend pretium non id urna. Fusce in augue leo, sed cursus nisl. Nullam vel tellus massa. Vivamus porttitor rutrum libero ac mattis. Aliquam congue malesuada mauris vitae dignissim.

<video id="my-video" class="video" controls>
  <source src="../../video/demo.mp4" type="video/mp4">
</video>
Start the Video once the Page has Loaded using the autoplay Attribute

Cras tellus enim, sagittis aer varius faucibus, molestie in dolor. Mauris molliadipisg elit, in vulputate est volutpat vitae. Pellentesque convallis nisl sit amet lacus luctus vel consequat ligula suscipit. Aliquam et metus sed tortor eleifend pretium non id urna. Fusce in augue leo, sed cursus nisl. Nullam vel tellus massa. Vivamus porttitor rutrum libero ac mattis. Aliquam congue malesuada mauris vitae dignissim.

<video id="my-video" class="video" autoplay>
  <source src="../../video/demo.mp4" type="video/mp4">
</video>
Displaying a Temporary Image until the Video has Loaded using the poster Attribute

Cras tellus enim, sagittis aer varius faucibus, molestie in dolor. Mauris molliadipisg elit, in vulputate est volutpat vitae. Pellentesque convallis nisl sit amet lacus luctus vel consequat ligula suscipit. Aliquam et metus sed tortor eleifend pretium non id urna. Fusce in augue leo, sed cursus nisl. Nullam vel tellus massa. Vivamus porttitor rutrum libero ac mattis. Aliquam congue malesuada mauris vitae dignissim.

<video id="my-video" class="video" poster="path_to_poster_image.jpg">
  <source src="../../video/demo.mp4" type="video/mp4">
</video>
Expressing the Video's Proportions using the height and width Attributes

Cras tellus enim, sagittis aer varius faucibus, molestie in dolor. Mauris molliadipisg elit, in vulputate est volutpat vitae. Pellentesque convallis nisl sit amet lacus luctus vel consequat ligula suscipit. Aliquam et metus sed tortor eleifend pretium non id urna. Fusce in augue leo, sed cursus nisl. Nullam vel tellus massa. Vivamus porttitor rutrum libero ac mattis. Aliquam congue malesuada mauris vitae dignissim.

<video id="my-video" class="video" height="100%" width="100%">
  <source src="../../video/demo.mp4" type="video/mp4">
</video>

Pellentesque venenatis tellus non purus tincidunt vitae ultrices tellus eleifend. Praesent quam augue, accumsan nec tempus dapibus, pharetra ac lacus. Nunc eleifend consequat justo id dapibus. In ut consequat massa. Nunc scelerisque suscipit leo nec imperdiet.

Nullam vel tellus

Pellentesque convallis nisl sit amet lacus luctus vel consequat ligula suscipit. Aliquam et metus sed tortor eleifend pretium non id urna. Fusce in augue leo, sed cursus nisl. Nullam vel tellus massa. Vivamus porttitor rutrum libero ac mattis. Aliquam congue malesuada mauris vitae dignissim. ❧



Articles