Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Falling back to download links

From: HTML5: Video and Audio in Depth

Video: Falling back to download links

So now we have our video and audio embedded with HTML5. We have multiple versions of our source to support different HTML5 browsers. We're falling back to Flash for browsers that don't support HTML5 media. There's still one more step we could take to make our video even more accessible and that's to provide download links and a fallback image. The reason for this is to support users on devices that don't support HTML5 or Flash, but could still potentially play the video if they are able to download it directly. These devices are typically older mobile phones or PDAs.

Falling back to download links

So now we have our video and audio embedded with HTML5. We have multiple versions of our source to support different HTML5 browsers. We're falling back to Flash for browsers that don't support HTML5 media. There's still one more step we could take to make our video even more accessible and that's to provide download links and a fallback image. The reason for this is to support users on devices that don't support HTML5 or Flash, but could still potentially play the video if they are able to download it directly. These devices are typically older mobile phones or PDAs.

The first step to do this is to add a simple paragraph after the video tag. So I am going to do that on our code. If you are following along in the exercise files, we're now in the 03_02 folder. Okay, I am going to drop down below our ending video tag, because this is going outside of our video tag, and I'm just going to provide simple paragraph and in the paragraph I am going to do a title. We'll put it in a strong tag that says Download Video.

And after that I'm going to provide the links to all our source versions. So link href and this would be our mp4 version. So I am just going to copy our source from our mp4 source and use that as the link URL. I'll call that MP4 and that anchor. I'm going to put a comma to separate the words. And then we'll do the same for our ogg source, and I'll call that OGG, and I am just going to copy that line and paste it after everything. Remove that last Comma.

We'll make this our webm source and tell that WEBM. I am just going to save that and jump over to Firefox and reload the page, and now we could see that we have download links below our video. So this is just an alternative way for users to access the video. Now they can download it by clicking on the links. All right, so the next thing we want to do is add a fallback image so that there isn't just a broken plug-in or blank space where the video should be. To do this, we have to modify our Flash embed code a little bit. So we'll go back and do that.

The Flash Media Playback Player uses an object and embed tag in its embed code, but this doesn't allow us to have a fallback image, because basically the embed tag acts as the fallback for the object tag. So we are going to need to change that to another Flash embed method that doesn't use the embed tag. So first let's breakup our embed code so we can see everything a little easier. So I am going to put line breaks ahead of the different parameter tags and the embed tag and I am going to drop the object down to the next line.

Okay, so now we have it broken up and the first thing I want to do is actually just go ahead and delete the embed tag. All right, now the way that we're going to make this work without the embed tag is actually add more information to our object tag and the first thing we're going to add is a type attribute and the type is application/x-shockwave-flash. And this is telling the object that it's a Flash Player and then we are going to add a data attribute.

The URL for the data attribute is going to be the same value for our Flash Player that's in the movie parameter, so I am going to go ahead and copy this. It's our SWF file that's used to load the video player. All right, so that's what we need to do to modify our code. What we are going to do next is add our fallback image and just like we added our fallback embed code after the source tags of our video tag, we are going to add our fallback image after the parameter tags in our object tag.

So it's the last thing in our object tag and it's just a simple image tag. And for the source of our fallback image, I often just use the poster image and so I am just going to copy our poster source here. But you can use any image you want here. You can use a generic image that just says something like your browser does not support video. Then beyond this we also want to add an alt and we'll say in alt No video supported and also a title here that says the same thing.

And we'll close that. Okay, so now we want to actually see this work. so what I am going to do is go back to the older version of Opera that I used in the Flash movie. That is a version of Opera before Opera supported HTML5 video, so that we can actually see how these fallbacks work. Now if I reload the Opera page you can see we're still supporting Flash so we can see the Flash Player still works. (Music plays) And then what I can do is actually go into the Opera preferences and you can do this in just about every browser.

I am going to turn off plug-ins. Now for Opera I would go to the Advanced Preferences tab and then the Content section, and then there's a checkbox that says Enable plug-ins. And you'll probably find something similar in your own browser. I am going to go ahead and disable plug-ins, I'll click OK, and then I am going to reload the page. We can see if I drag this it's now the image. It's now our poster image here instead of the Flash fallback and if we roll over it, you can see what we're putting on the title attribute. It says No video supported, so that's the value of adding the title attribute.

All right, so now we have it set up so that if the browser doesn't support HTML5, it will fall back to Flash, and if it doesn't support Flash, it will fall back to our fallback image. So again this step is to support that extra group of users on older devices and it is optional. If you're worried about your content being downloaded and spread across the Internet without your permission, you might want to skip this step. But in reality no video that's free to view on the Internet is 100% safe from being copied. So sometimes it's better to just support your users than to worry about that. But with that we finished our full HTML5 embed code.

I'll just back and look at it. I know it's probably not the most attractive code ever, but it's what we need to support our whole audience and hopefully in years to come it will get much easier than this to use HTML5 video and audio.

Show transcript

This video is part of

Image for HTML5: Video and Audio in Depth
HTML5: Video and Audio in Depth

37 video lessons · 14613 viewers

Steve Heffernan
Author

 
Expand all | Collapse all
  1. 1m 24s
    1. Welcome
      42s
    2. Using the exercise files
      42s
  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 17s
    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 45s
  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
      35s
    2. Autobuffer or preload?
      56s
    3. Load progress in Firefox 3.6
      41s
    4. Android 2.0 issues
      1m 5s
    5. iOS 3 issues
      1m 20s
  8. 2m 8s
    1. Flight of the Navigator
      50s
    2. ZEN Audio Player by simurai
      34s
    3. The Wilderness Downtown by Google and Arcade Fire
      44s
  9. 1m 40s
    1. Further exploration
      1m 40s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
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

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: Video and Audio in Depth.

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
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.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

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
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.