An html5 video control only supports the default android mp4 and 3gp formats.

Source: Internet
Author: User

Copy codeThe Code is as follows:
<! DOCTYPE html>
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> </title>
</Head>
<Body>

<Div id = "divVideo"> </div>

// Due to limited js levels, don't like it or not. It's okay to check it out. video is a new control in html5. You can check it out.

<Script type = "text/javascript">

// Mp4 is a common format supported by ios and android
Function playVideo (opt ){
If (typeof (opt) = "undefined "){
Alert ("Please input required parameters! ");
Return;
}
If (typeof (opt. elemts) = "undefined "){
Alert ("specify the object to be inserted in the player! ");
Return;
}
If (typeof (opt. src) = "undefined "){
Alert ("specify the path of the video to be played! ");
Return;
}
Var _ this = this;
_ This. elemts = opt. elemts; // the object to be inserted by the player.
_ This. src = opt. src; // video URL (required)
_ This. width = opt. width> 0? Opt. width + "px": "100%"; // width (100% by default)
_ This. height = opt. height> 0? Opt. height + "px": "100%"; // height (100% by default)
_ This. autoplay = opt. autoplay = "true "? "Autoplay": ""; // automatic playback (true indicates automatic playback)
_ This. poster = opt. poster; // specifies the video album art and the album art during playback.
_ This. preload = opt. preload = "true "? "Preload": ""; // pre-load (start loading when true)
_ This. loop = opt. loop = "true "? "Loop": ""; // loop playback (when true, loop playback)
Var str = "<video id = 'playvideo' controls"; // spell the video control based on the set attribute value.
Str + = "width = '" + _ this. width + "'height = '" + _ this. height + "'" + _ this. autoplay + "" + _ this. preload + "" + _ this. loop + "";
If (typeof (_ this. poster )! = "Undefined "){
Str + = "poster = '" + _ this. poster + "'> ";
} Else {
Str + = "> ";
}
Str + = "<source src = '" + _ this. src + "'/> ";
Str + = "</video> ";
This. elemt. innerHTML = str; // place str in the object to be inserted.
}
PlayVideo ({
// All parameters, elemts and src are required.
// Elemt is the container to be inserted into the playback control, src is the video file address, preload is the preload, and autoplay is automatically played when the page is accessed
// Poster indicates the picture that is taken before playback, loop indicates whether to play cyclically, and width and heigth are 100% by default.
Elemt: document. getElementById ("divVideo "),
Src: "3.mp4 ",
Preload: "true ",
Autoplay: "true ",
Poster :"",
Loop: "true ",
Width :"",
Heigth :""
});
</Script>
</Body>
</Html>

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.