Introduction to HTML5 video tags

Source: Internet
Author: User

Comments: HTML video is suitable for HTML 5 +. It is used to define the streaming media of videos watched online. Here is a brief introduction to make it easy for friends who need it.

HTML <video> is applicable to HTML 5 + and is used to define the streaming media of videos watched online.


The Code is as follows:
<Video width = "320" height = "240" src = "http://www.jb51.net/movie.ogg" controls = "controls">
Here is the comment text. If the HTML 5 browser is not supported, the text here will be displayed. If yes, the video is displayed directly, ignoring text.
</Video>

In HTML 4 and earlier versions, If You Want To embed videos that you want to watch online on a webpage, you generally need to use the Flash video stream by using the <object> and <embed> labels, you can use a browser to play swf, flv, and other video files, provided that the browser must install a third-party plug-in: Adobe Flash Player. Modern smartphones and iPad generally do not support Flash, so they cannot view videos on webpages. HTML 5 has changed the fact that Web developers can easily load video files without any third-party plug-ins by using the <video> tag.

Attribute Value Description
Autoplay Autoplay If this attribute appears, the video will be played immediately after it is ready.
Controls Controls If this attribute is displayed, the control, such as the play button, is displayed to the user.
Height Pixel value Set the height of the video player.
Loop Loop If this attribute is displayed, the media file starts playing again after being played.
Preload Auto/meta/none Specifies whether to pre-load the video. Possible values:
Auto-load the entire video after the page is loaded
Meta-only metadata is loaded after the page is loaded.
None-videos are not loaded after the page is loaded.
* Src Video address The URL of the video to be played. We recommend that you use an absolute address.
Width Pixel value Set the width of the video player.

How do I write compatible video tags?

Because the old browsers and Internet Explorer do not support the <video> element, considering compatibility, we must find a solution that supports Flash files for these browsers. Unfortunately, like HTML 5 audio, video file formats are involved. Firefox and Safari/Chrome support methods are different. Therefore, if you want to use HTML 5 videos at this time, you need to create three video versions. OGG, MP4, FLV/SWF


The Code is as follows:
<Video width = "320" height = "240" controls>
<! -- Compatible with Firefox -->
<Source src = "http://www.jb51.net/movie.ogg" type = "video/ogg"/>
<! -- Compatible with Safari/Chrome -->
<Source src = "http://www.jb51.net/movie.mp4" type = "video/mp4"/>
<! -- If the browser does not support video tags, use flash -->
<Embed src = "http://www.jb51.net/movie.swf" type = "application/x-shockwave-flash"
Width = "320" height = "240" allowscriptaccess = "always" allowfullscreen = "true"> </embed>
</Video>


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.