Copy Code code as follows:
<! DOCTYPE html>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title></title>
<body>
<div id= "Divvideo" ></div>
Because JS level is limited, do not like to spray, all when nothing to see, video is the new control in HTML5, we can see
<script type= "Text/javascript" >
MP4 is a widely supported format for iOS and Android
function PlayVideo (opt) {
if (typeof (opt) = "undefined") {
Alert ("Please pass in the necessary parameters!") ");
Return
}
if (typeof (opt.elemt) = = "undefined") {
Alert ("Please specify the object to be inserted by the player!") ");
Return
}
if (typeof (opt.src) = = "undefined") {
Alert (Please specify the path to play the video!) ");
Return
}
var _this = this;
_THIS.ELEMT = OPT.ELEMT; objects to be inserted by the viewer
_THIS.SRC = OPT.SRC; The URL of the video (must be set)
_this.width = opt.width > 0? Opt.width + "px": "100%"; Width (default 100%)
_this.height = opt.height > 0? Opt.height + "px": "100%"; Height (default 100%)
_this.autoplay = Opt.autoplay = = "true"? "AutoPlay": ""; Auto Play (True to AutoPlay)
_this.poster = Opt.poster; Video cover, when playing the cover picture
_this.preload = Opt.preload = = "true"? "Preload": ""; Preload (Start loading when true)
_this.loop = Opt.loop = = "true"? "Loop": ""; Loop Play (loop playback true)
var str = "<video id= ' PlayVideo ' controls"; Spelling the video control based on the value of the property being set
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; Put Str in the object you want to insert
}
PlayVideo ({
All parameters, ELEMT and SRC are required to fill in others to see how requirements
ELEMT for the playback control to insert the container, src for the video file address, preload for preload, autoplay whether the page entry will automatically play
Poster for the camera before playback, loop for loop playback, width and heigth default 100%
Elemt:document.getElementById ("Divvideo"),
SRC: "3.mp4",
Preload: "true",
AutoPlay: "True",
Poster: "",
Loop: "True",
Width: "",
Heigth: ""
});
</script>
</body>