Start learning with our library of video tutorials taught by experts. Get started

HTML5 First Look

Adding video


From:

HTML5 First Look

with James Williamson
Expand all | Collapse all
  1. 3m 56s
    1. Welcome
      1m 1s
    2. Using the exercise files
      1m 50s
    3. Who is this course for?
      1m 5s
  2. 21m 12s
    1. Exploring prior standards
      4m 26s
    2. Why do we need HTML5?
      3m 32s
    3. HTML5 timeline
      4m 24s
    4. Current HTML5 support
      4m 25s
    5. What HTML5 is (and what it isn't)
      4m 25s
  3. 27m 49s
    1. HTML5 vs. HTML4
      3m 25s
    2. New structural tags
      6m 1s
    3. New content tags
      4m 7s
    4. New application-focused tags
      5m 32s
    5. Deprecated elements
      4m 28s
    6. API overview
      4m 16s
  4. 22m 29s
    1. Content models
      5m 33s
    2. Understanding the outline algorithm
      3m 21s
    3. The role of ‹div› tags
      4m 20s
    4. Using ID and class attributes
      2m 6s
    5. DOCTYPE declarations
      4m 16s
    6. Character encoding
      2m 53s
  5. 41m 27s
    1. Basic page structure
      3m 40s
    2. Structuring top-level elements
      7m 30s
    3. Structuring interior content
      8m 42s
    4. Building headers
      9m 11s
    5. Checking document outlines
      5m 46s
    6. Ensuring cross-browser structure
      6m 38s
  6. 27m 53s
    1. New input types
      5m 57s
    2. Setting form autofocus
      2m 53s
    3. Using placeholder data
      4m 4s
    4. Marking required fields
      3m 24s
    5. Working with number inputs
      5m 49s
    6. Using date pickers
      5m 46s
  7. 1h 1m
    1. Canvas overview
      6m 21s
    2. Adding canvas content
      8m 58s
    3. Drawing in the canvas environment
      12m 9s
    4. Drag-and-drop API overview
      6m 18s
    5. Offline applications overview
      7m 11s
    6. Video overview
      5m 45s
    7. Encoding video
      8m 23s
    8. Adding video
      5m 58s
  8. 57m 33s
    1. Geolocation API overview
      5m 50s
    2. Web storage API overview
      5m 40s
    3. WebSockets overview
      4m 16s
    4. CSS3 overview
      6m 38s
    5. Enhancing typography with CSS3
      7m 42s
    6. Using @font-face
      7m 11s
    7. Styling HTML5 with CSS3
      10m 23s
    8. Using CSS3 transitions
      9m 53s
  9. 5m 6s
    1. Final thoughts
      3m 49s
    2. Goodbye
      1m 17s

Video: Adding video

Now that we have our newly encoded video, it's time to add it to our page using HTML5 markup. As we explore the markup necessary to use video with HTML5, we're also going to explore how to use fallback content to make our video more cross-browser compliant. So I have the trails.htm file opened from the 06_08 folder. I'm going to scroll down to where our video needs to be added into our code, which is around line 114 or so. We've got a nice little comment there that says place our video here. We'll just go ahead and remove that. Okay, so actually adding video to your page is extremely easy.

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
Please wait...
HTML5 First Look
4h 28m Beginner Aug 23, 2010

Viewers: in countries Watching now:

In HTML5 First Look, author James Williamson introduces the newest HTML specification, providing a high-level overview of HTML5 in its current state, how it differs from HTML 4, the current level of support in various browsers and mobile devices, and how the specification might evolve in the future. Exercise files accompany the course.

Topics include:
  • Understanding the history of HTML5
  • Using new tags
  • Understanding HTML5 semantics
  • Coding ID and class attributes in HTML5
  • Structuring documents
  • Building forms
  • Exploring HTML5 native APIs
  • Encoding and adding HTML5 video
  • Exploring associated technologies such as CSS3
Subjects:
Developer Web Web Design Web Development
Software:
HTML
Author:
James Williamson

Adding video

Now that we have our newly encoded video, it's time to add it to our page using HTML5 markup. As we explore the markup necessary to use video with HTML5, we're also going to explore how to use fallback content to make our video more cross-browser compliant. So I have the trails.htm file opened from the 06_08 folder. I'm going to scroll down to where our video needs to be added into our code, which is around line 114 or so. We've got a nice little comment there that says place our video here. We'll just go ahead and remove that. Okay, so actually adding video to your page is extremely easy.

We're just going to use a video tag and inside our video tag, we're going to set a source for that. Our source for this one is going to be _video/explore_promo.ogv. So remember that's the video file that we encoded in our last exercise. We're going go ahead and give it a width of 420 and then give it a height of 236. That's going to be the height on that. I'm just going to close that and then close the video tag.

That's really all we need to do to place a video on a page. I'm going to go ahead and save this. I'm going to preview this using Firefox. So let's go ahead and preview that using Firefox. As you can see, our video would work just fine, but we don't have any controls. I can't play it. I can't stop it. I can't pause it, any of that stuff. So if you're looking for custom controls, you can use the HTML5 Video API to wire up your own, but if you're looking for just standard play, pause, seekbar controls, you can easily enable them yourself within the tag.

So I'm going to go back into my code. Inside the video tag, I'm just going to go ahead and type in controls. Again, this is a Boolean value and it just controls, just enables them. So I'm just going to type in controls. I'm also going to type in preload="false". I don't want it to preload the video before the user plays it. That might slow the rest of the page down. So I'm going to go ahead and save that. Now let's try this again. I'm going to test this in Firefox again. Scrolling down, now I have some controls. (Music Playing) (Male speaker: Beautiful scenery, plenty of places to ride.) Some audio controls, got a seekbar, working just fine. Cool! Now if I try the same exact video in Safari, eh nothing. This is because Safari doesn't support Ogg Theora file format.

So I'm going to back into my code. Now I'm going to change the file format from OGV to MP4. So if I save this and now test this in Safari - (Music Playing) The video works just fine. Okay, that's not a great solution having to keep going back and forth and switching file formats. So there's obviously a better solution for this. What we're going to use is inside the video tag, we can embed a source tag. The source tag allows us to define multiple video file formats in the order that we want them tried.

So the video player would first try to upload at the first resource. If that doesn't work, it will move on to the next one. So let's go into our code again and let's try that. So what I'm going to do is get rid of the source attribute inside the video tag. I'm just going to leave it with the width, height, and the controls and preload. Then inside the video tag itself, I'm going to create a source tag. For source, I'm type in for the first source, _video/explore_promo.mp4, and then I'm going to pass along a type for that.

The type of this is going to be video/mp4. Now if you're going to host these yourself, your server needs to understand that mime type. So again, you may need to go into your server and set those mime types. Now in order to save myself a little bit of typing, I'm simply going to copy this tag and paste it again and change mp4 to ogv and change again the file type to ogg. That's the mime type for that here. Now, you might be wondering well, is there a reason that you did this in the order that you did it? And actually there is.

The iPhone uses the first video source available and if it doesn't see one that it recognizes, it just sort of fails to implement the video. So there is a reason that the MP4 video is served first in this particular list. Okay, now I'm going to save this. I'll test this in Firefox first. (Music Playing) Video works fine. Now I'm going to back in. I'm going to test this in Safari. (Music Playing) Video works fine here as well. I could continue to test it in Chrome and it would work fine as well.

So our video is a little bit more cross-browser compliant. Now we can continue to provide fallback content. If we wanted to after the last source type for example, we could do an object tag that loads up some flash fallback content if it was unsuccessful loading the MP4 or the OGG file. So you can be a lot more specific with this if you want to. So I think you'll agree, even though we've had to deal with multiple codecs, the actual implementation wasn't that hard. Now keep in mind that this is just an overview of video deployment with HTML5. For a more thorough exploration of deploying HTML5 video, complete with code examples and detailed notes, check out Kroc Camen's fantastic article, "HTML5 - Video for Everybody." This has got some examples.

It describes how it works and towards the bottom of this, it's got code that you can use yourself. So right here we have some copy and paste code or you just swap out your own source files for a cross- browser compliant HTML5 video. The really cool thing about his technique is that no JavaScript is employed at all, which is really, really cool. Also, remember to checkout some of the open-source players I mentioned earlier in the HTML5 video overview like the videojs.com and the html5video.org. So although it's not quite as simple as just using a video tag on the page, as you can see it doesn't take that much extra work to go ahead and deploy HTML5 video on your sites right now.

So this is something within the specification that you could deploy, if you felt it was right for your own sites and your own applications.

There are currently no FAQs about HTML5 First Look.

Share a link to this course
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.
Upgrade now


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.

Upgrade now

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

Congratulations

You have completed HTML5 First Look.

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


OK
Become a member to add this course to a playlist

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

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

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:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Welcome to the redesigned course page.

We’ve moved some things around, and now you can



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.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com 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 lynda.com.

Sign up and receive emails about lynda.com and our online training library:

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

   
submit Lightbox submit clicked