Posts in current category
May 03, 2021 13:05 HTML5
In this section, you'll learn how video works in HTML5, the video formats supported by mainstream browsers, and how to control video on a web page.
Many sites use video. HTML5 provides the standard for displaying video.
Until now, there was no standard for displaying video on a Web page.
Today, most videos are displayed through plug-ins such as Flash. However, not all browsers have the same plug-in.
HTML5 provides a standard way to include video through video elements.
Internet Explorer 9 Plus, Firefox, Opera, Chrome, and Safari support this element.
Note: Internet Explorer 8 or earlier versions of IE do not support the element.
To display a video in HTML5, all you need is:
The element provides playback, pause, and volume controls to control the video.
At the same time, the element also provides the width and height properties to control the size of the video. I f you set the height and width, the desired video space is preserved when the page loads. If you don't set these properties, the browser doesn't know the size of the video, the browser can no longer load when it retains a specific space, and the page changes depending on the size of the original video.
The content inserted between the label and the label is provided to browsers that do not support video elements.
The element supports multiple elements. E lements can link different video files. The browser will use the first recognizable format:
Currently, the elements support three video formats: MP4, WebM, and Ogg:
|Internet Explorer 9+||YES||NO||NO|
HTML5 and the elements also have methods, properties, and events.
Methods include playing, pausing, loading, and so on. P roperties such as length of time, volume, etc. can be read or set. One of the DOM events can notify you, for example, that the element starts playing, pauses, stops, and so on.
The simple method in the example shows us how to use the element, read and set properties, and how to call a method.
Create simple play/pause and resize controls for videos:
The example above calls two methods: play() and pause(). It uses two properties at the same time: paused and width.Try it out . . .
HTML DOM Reference Manual: HTML DOM Video Object