HTML 5 Videos--Video elements

Source: Internet
Author: User

The video element supports three different formats

IE Firefox Opera Chrome Safari
Ogg file with Theora video encoding and Vorbis audio encoding No 3.5+ 10.5+ 5.0+ No
MPEG 4 files with H + video encoding and AAC audio encoding 9.0+ No No 5.0+ 3.0+
WebM file with VP8 video encoding and Vorbis audio encoding No 4.0+ 10.6+ 6.0+ No

1. Set up a file in ogg format

<video src= "Movie.ogg" controls= "Controls" height= "200px" width= "300px" >
Your browser does not support the video tag.
</video>

EXECUTE as follows:

When the browser does not support Ogg format, it displays "Your browser does not support video tags." ”

2. Set multiple formats
<video width= "height=" poster= "Suk.png" controls>
<source src= "Movie.mp4" type= "Video/mp4" >
<source src= "Movie.ogg" type= "Video/ogg" >
Your browser does not support the video tag.
</video>

EXECUTE as follows:

If you set a default picture for your video. You can also add additional properties.

The properties of the <video> tag are as follows:

Controls/controls= "Controls" show play button
Autoplay/autoplay= "AutoPlay" Play Now
Loop/loop= "loop" loop playback
muted/muted= "Muted" mute
preload/preload= "preload" load video D
poster= "path" displays the default picture

3. Custom Play pause and size (Video + DOM)

<button onclick= "Playpause ()" > Play/Pause </button>
<button onclick= "Makenormal ()" > Change size </button>

<video id= "video1" width= ">"
<source src= "Movie.mp4" type= "Video/mp4" >
<source src= "Movie.ogg" type= "Video/ogg" >
Your browser does not support the video tag.
</video>

Write JavaScript underneath the HTML

<script type= "Text/javascript" >
var Myvideo=document.getelementbyid ("Video1");

function Playpause ()
{
I f (myvideo.paused)
Myvideo.play (); Play
Else
Myvideo.pause (); Time out
}

function Makenormal ()
{
myvideo.width=420; Custom width, highly adaptive
}
</script>

EXECUTE as follows:

Most browsers support video methods, properties, and events (to be understood later)

Method Properties Events
Play () Currentsrc Play
Pause () CurrentTime Pause
Load () Videowidth immediate execution-video element before execution Progress
Canplaytype () Videoheight immediate execution-video element before execution Error
Duration Timeupdate
Ended Ended
Error Abort
Paused Empty
Muted Emptied
Seeking Waiting
Volume Loadedmetadata
Height
Width

Below is the method properties and event reference for HTML5 video and audio

Http://www.w3school.com.cn/tags/html_ref_audio_video_dom.asp

HTML 5 Videos--Video elements

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.