HTML5 video (b) <video> using DOM for control

Source: Internet
Author: User

HTML5 <video> using DOM for control

HTML5 <video> elements also have methods, properties, and Events.

The methods are used for playing, pausing, loading, and so On. The properties (such as length, volume, etc.) can be read or set. DOM events can inform you, for example, that the,<video> element starts playing, paused, stopped, and so On.

Two methods were called: play () and pause (). It uses two properties at the same time: paused and Width.

<!DOCTYPE HTML><HTML>    <Head>        <MetaCharSet= "utf-8" />        <title></title>    </Head>    <Body>        <Divstyle= "text-align:center;">            <VideoID= "video1"width= "420"style= "margin-top:55px;">                <Sourcesrc= "img/mov_bbb.mp4"type= "video/mp4" />                <Sourcesrc= "img/mov_bbb.ogg"type= "video/ogg" />Your Browser does not support HTML5 Video. </Video>            <BR/>            <Buttononclick= "playpause ()">Play/pause</Button>            <Buttononclick= "makebig ()">Big</Button>            <Buttononclick= "makenormal ()">In</Button>            <Buttononclick= "makesmall ()">Small</Button>        </Div>        <Scripttype= "text/javascript">            varMyvideo=document.getElementById ("Video1"); functionplaypause () {if(myvideo.paused) Myvideo.play (); ElseMyvideo.pause (); }            functionmakebig () {myvideo.width= 560; }            functionMakesmall () {myvideo.width=  the; }            functionmakenormal () {myvideo.width= 420; }        </Script>    </Body></HTML>

1. Chrome Browser Test

2, IE9 in the test

3. IE8 Browser Test

HTML5 video (b) <video> control using the DOM

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.