Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now

Using the video and audio tags

Using the video and audio tags provides you with in-depth training on Video. Taught by Steve Heffern… Show More

HTML5: Video and Audio in Depth

with Steve Heffernan

Video: Using the video and audio tags

Using the video and audio tags provides you with in-depth training on Video. Taught by Steve Heffernan as part of the HTML5: Video and Audio in Depth
Expand all | Collapse all
  1. 1m 24s
    1. Welcome
    2. Using the exercise files
  2. 15m 18s
    1. Understanding HTML5 video and audio
      4m 46s
    2. The state of HTML5 video and audio
      4m 29s
    3. Understanding the format war
      3m 53s
    4. Configuring your server to deliver HTML5 media formats
      2m 10s
  3. 32m 36s
    1. Using the video and audio tags
      5m 34s
    2. Using multiple sources for browser compatibility
      5m 53s
    3. Preloading
      4m 16s
    4. Autoplaying
      2m 2s
    5. Looping
      5m 11s
    6. Setting a poster frame
      3m 43s
    7. Setting the video width and height
      3m 40s
    8. Displaying subtitles and captions
      2m 17s
  4. 12m 40s
    1. Falling back to Flash
      4m 4s
    2. Falling back to download links
      6m 21s
    3. Using an embed code builder
      2m 15s
  5. 22m 11s
    1. Understanding HTML5 video formats
      5m 10s
    2. Understanding HTML5 audio formats
      2m 57s
    3. Encoding MP4/H.264 video with HandBrake
      3m 13s
    4. Encoding Ogg, Theora, and WebM with Firefogg
      3m 18s
    5. Encoding audio formats with VLC
      5m 54s
    6. Automating video and audio encoding
      1m 39s
  6. 34m 59s
    1. Setting up the JavaScript
      4m 39s
    2. Creating Play and Pause buttons
      7m 52s
    3. Creating a Play Progress bar
      5m 49s
    4. Creating a Load Progress bar
      9m 29s
    5. Creating a Current Time and Duration display
      7m 10s
  7. 4m 37s
    1. Overview of known issues
    2. Autobuffer or preload?
    3. Load progress in Firefox 3.6
    4. Android 2.0 issues
      1m 5s
    5. iOS 3 issues
      1m 20s
  8. 2m 8s
    1. Flight of the Navigator
    2. ZEN Audio Player by simurai
    3. The Wilderness Downtown by Google and Arcade Fire
  9. 1m 40s
    1. Further exploration
      1m 40s

please wait ...
Using the video and audio tags
Video Duration: 5m 34s 2h 7m Intermediate


Using the video and audio tags provides you with in-depth training on Video. Taught by Steve Heffernan as part of the HTML5: Video and Audio in Depth

View Course Description

In this course, author Steve Heffernan contextualizes the state of HTML5 audio and video and shows how to embed media into a web page using HTML5. The course sheds light on configuring the new HTML5 audio and video tags, ensuring backwards compatibility by setting alternative playback methods, encoding the needed file formats, and building custom controls with JavaScript. Also included are tutorials on troubleshooting known issues and reviewing real-world examples of HTML5 audio and video.

Topics include:
  • Understanding the differences in media formats
  • Preloading, autoplaying, and looping in HTML5
  • Setting a video's width and height attributes
  • Displaying subtitles and captions
  • Generating embed code with an embed code builder
  • Encoding files using HandBrake, Firefogg, and VLC
  • Creating a load progress bar
  • Recognizing Android and iOS issues
Video Web

Using the video and audio tags

So now we're going to get into using the video and audio tags. The video you see here-- (Music playing) It's not being played back with any third-party plug-ins like Flash. It's using the video tag. So now, just like the image tag for images, we have a video tag for video and an audio tag for audio. That's what I'm going to show you how to use today. If you have the exercise files, we would be in the, let's see, 2-01 and the video.htm file.

I'm going to go ahead and drag that to my text editor. As we scroll down the page, we'll see a comment that says and that's where we're going to start. The first thing we need is an opening and closing video tag. Now you'll notice compared to an image tag we have a closing video tag and that's not optional. You have to have the closing video tag and there's couple of reasons for that. One is so that we can put other related tags inside of it and that includes things like the source tags for providing other sources or the track tag, which we will go in to later.

Then the other reason is to provide fallback content. So if the video tag isn't supported, it can fallback to anything we have in this area. So this can be as simple as a paragraph tag that says, "Your browser does not support video." And then beyond that we could also put a third-party plug-in player here like a Flash Player so that I could fallback to that for browsers that don't support HTML5. We will get into all that later but let's keep going with the video tag and next thing we need is the source attribute.

So it's very similar to the image tag and the source I'm going to use is in our video assets folder, which is at ../_video and we're going to use the podcast.ogv file. I'm going to use the OGV file because I know this will work in the browser I'm using for this example, Firefox. If you're using Safari or Internet Explorer 9, you can use a .mp4 file and that will work for this exercise in those browsers. So, I'm going to save that and our file is at the 2-01 folder, file video.htm, open that up.

And here we go. Here's the video that we just embedded but we see the video and it's actually showing the first frame, but we can't do anything with it. We can't play the video and it's not just playing by itself. It's because we haven't given any way to control the video. So, the next thing we need to do is add controls. So I'm going to go back to my text editor and to add controls, all we need to do is add the controls attribute. It's as simple as that. It's a Boolean attribute so it's either true or false.

If we include it, it's true. If we exclude it it's false. If you're using an XHTML doc type, you can always expand it to controls="controls". But if you're using the HTML5 doc type, which id we scroll up it looks like just . You don't need to expand it like that. We can just leave it, "controls". So do that and I will go ahead and save the file and we'll go back to our Web browser, reload the page and now we have controls. We can play it.

(Video playing) We can pause the video, we can scrub along the timeline, and we can change the volume. So awesome. That's as simple as it is to embed a video using HTML5. Let's go and do the same for audio. Go back to our text editor and if you scroll down a little farther you'll see a comment that says and so that's where we put our audio tag, starting with an opening and closing audio tag. We will do our fallback that says, Your browser does not support audio.

And then our source attribute, which in this case is at ../_audio in our audio folder, and the file is podcast-audio.oga. So this again will work in Firefox. You can use the M4A file if you're using Safari or Internet Explorer 9. And then we also want our controls. So I'll save that, go back to our browser, reload the page. Now we have our audio here as well. We can play it. (Audio playing) It works, awesome.

Okay, let's go back to our code and I just want to stop here and point out that ideally, in the future this is what it will look like to embed video in your web page, say in 10 years when everyone has HTML5-compatible browsers and they all support the same video format. It's very clean, readable, not a lot of object embed param tags that you'd find with the plug-ins. Definitely worth working towards. But currently, this isn't enough. If we load this in IE 6, 7 or 8, you'll get the paragraph that says Video is not supported, which obviously isn't ideal because this could be half of your user-base.

If we load this on an iPhone or for that matter Safari or IE 9 you'll get a broken video because those browsers don't support the ogg formats that I used in the example. So from here it's going to get a little dirtier as we build in support for multiple formats and fallbacks for older browsers and devices, but someday it will be this simple and I'm sure we're all looking forward to that.

There are currently no FAQs about HTML5: Video and Audio in Depth.






Don't show this message again
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.

Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now Already a member? Log in

* Estimated file size

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.

Mark all as unwatched Cancel


You have completed HTML5: Video and Audio in Depth.

Return to your organization's learning portal to continue training, or close this page.


Upgrade to View Courses Offline


With our new Desktop App, Annual Premium Members can download courses for Internet-free viewing.

Upgrade Now

After upgrading, download Desktop App Here.

Become a Member and Create Custom Playlists

Join today and get unlimited access to the entire library of online learning video courses—and create as many playlists as you like.

Get started

Already a member?

Log in

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

You started this assessment previously and didn’t complete it.

You can pick up where you left off, or start over.

Resume Start over

Learn more, save more. Upgrade today!

Get our Annual Premium Membership at our best savings yet.

Upgrade to our Annual Premium Membership today and get even more value from your subscription:

“In a way, I feel like you are rooting for me. Like you are really invested in my experience, and want me to get as much out of these courses as possible this is the best place to start on your journey to learning new material.”— Nadine H.

Thanks for signing up.

We’ll send you a confirmation email shortly.

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from

Sign up and receive emails about and our online training library:

Here’s our privacy policy with more details about how we handle your information.

submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.