Video events and methods-dom

Source: Internet
Author: User

<Video> elements also have methods, attributes, and events.
The methods are used for playing, pausing, and loading. The attributes (such as duration and volume) can be read or set. The DOM event can notify you, for example, the <video> element starts to play, has been paused, has been stopped, and so on.
The Simple Method in the following example demonstrates how to use the <video> element, read and set attributes, and call methods.
Create simple play/pause and resize controls for the video:

<Div style = "text-align: center;"> <button onclick = "playpause ()"> play/pause </button> <button onclick = "makebig () "> large </button> <button onclick =" makenormal () "> medium </button> <button onclick =" makesmall () "> small </button> <br/> <video ID =" video1 "width =" 420 "style =" margin-top: 15px; "> <source src ="/example/HTML5/mov_bbb.mp4 "type =" Video/MP4 "/> <source src ="/example/HTML5/mov_bbb.ogg "type =" Video/ ogg "/> your browser does not support HTML5 video. </video> </div> <SCRIPT type = "text/JavaScript"> var myvideo = document. getelementbyid ("video1"); function playpause () {If (myvideo. paused) myvideo. play (); else myvideo. pause ();} function makebig () {myvideo. width = 560;} function makesmall () {myvideo. width = 320;} function makenormal () {myvideo. width = 420 ;}</SCRIPT>


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: 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.