HTML5 video Tag implementation: general article

Source: Internet
Author: User

With the rapid development of the Internet and the application of HTML5, more and more projects are used in Video,audio as a common label.

Let's start with the general usage of the video tag below.

The properties of the video tag are as follows:

Note: The control property is for adding play, pause, and volume controls.

General usage:

<class= "Videocon"><width= "750 "  height="  id= "Videop"  src= "Video.mp4 " ></ Video > </ Div >  

Of course, you can pause, play the video, using the following methods:

function Playpause () {   var myvideo = document.getElementById (' Videop ');    if (myvideo.paused) {        myvideo.play ();   } Else {    myvideo.pause ();   }    }

Of course, the video element allows multiple source elements. The source element can link different video files. The browser will use the first recognizable format:

As follows:

<Videowidth= " the"Height= "+"Controls= "Controls">  <Sourcesrc= "Movie.ogg"type= "Video/ogg">  <Sourcesrc= "Movie.mp4"type= "Video/mp4">Your Browser does not support the video tag.</Video>

To introduce the use of audio tags (same as video use):

<src= "Song.mp3"  controls= "Controls"  loop= " Loop "  autoplay=" AutoPlay "> Pro Your browser does not support HTML5 's audio tag </  Audio>

Audio is not just a label. He is also an object under Window, the object has properties and methods, as an object what are his common methods?
Object properties:
currenttime get current playback time
duration Total time to get songs
play is playing back True/false
pause is paused to return True/false


Object method:
Play () playing songs
Pause () pauses the song
load () reload Song

Again as below:

<AudioControls= "Controls">     <Sourcesrc= "Music.ogg" />    <Sourcesrc= "Music.mp3" />    <Sourcesrc= "Music.wav" /> </Audio> 

HTML5 video Tag implementation: general 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.