YouTube Adds HTML 5 Embedding of Videos

YouTube Adds HTML 5 Embedding of Videos

Here is some good news for YouTube fanboys, now you can embed YouTube videos using the new HTML5 embed code. The YouTube api blog recently announced that the team is experimenting with a new embed code that uses the iframe tag to switch between the flash and HTML5 interface.

YouTube added support for HTML5 earlier this year, followed by another popular video sharing site – Vimeo. The HTML5 video playback was limited to only a few browsers e.g Google Chrome, Safari and users were not given any embed code for the uploaded videos.

With the new iframe tag embedded in your website, the code will automatically detect whether you are using a browser that supports HTML5 or not.

The iframe code for embedding YouTube videos is as follows, simply copy the Video ID and replace in the code below:

<iframe type=”text/html” width=”640″ height=”385″ src=”http://www.youtube.com/embed/VIDEO_ID” frameborder=”0″>
</iframe>

Here is an example video embedded using the new HTML5 embed code:

Users will be able to view the embedded video in both Flash and HTML5 players, this depends on their viewing environment and browser preferences. You can find a complete list of HTML5 video players at this page

Please note that those videos which contain inline advertisements will be shown using Flash because HTML5 can not play the videos containing advertisements. The advantage of the new HTML5 embed code is that it will allow embed codes to work on various mobile devices, which use a built in player instead of either Flash or HTML5.

The new embed code is just a testing feature, more improvements are on the way. [ via YouTube API blog ]

5 thoughts on “YouTube Adds HTML 5 Embedding of Videos”

  1. i have flashblock on my chrome and it showed me the video was in flash =) i mean i must unblock it before watching =)

    so its still flash

  2. Cool. One question for you though: is there a way to detect the end of video playback? I’d like to be able to close the iframe when the video has stopped playing.

  3. Hey guys, hate to say it, but that video “example” you have in the site above is flash player from youtube, not the html5 tag.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>