코드 사본은 다음과 같습니다.
<! doctype html>
<html xmlns = "http://www.w3.org/1999/xhtml">
<헤드>
<meta http-equiv = "content-type"content = "text /html; charset = utf-8" />
<제목> </title>
</head>
<body>
<div id = "divvidideo"> </div>
// JS 수준이 제한되어 있기 때문에 마음에 들지 않으면 비판하지 마십시오. 괜찮은 척. 비디오는 HTML5의 새로운 컨트롤입니다. 당신은 그것을 확인할 수 있습니다.
<script type = "text/javaScript">
// mp4는 iOS와 Android에서 일반적으로 지원되는 형식입니다.
기능 playvideo (opt) {
if (typeof (opt) == "undefined") {
경고 ( "필요한 매개 변수를 전달하십시오!");
반품;
}
if (typeof (opt.elemt) == "undefined") {
ALERT ( "플레이어가 삽입 할 객체를 지정하십시오!");
반품;
}
if (typeof (opt.src) == "undefined") {
Alert ( "비디오 재생 경로를 지정하십시오!");
반품;
}
var _this = this;
_this.elemt = opt.elemt; // 플레이어가 삽입 할 객체
_this.src = opt.src; // 비디오의 URL (필수)
_this.width = opt.width> 0? opt.width + "px": "100%"; // 너비 (기본 100%)
_this.height = opt.height> 0? opt.height + "px": "100%"; // 높이 (기본 100%)
_this.AutOplay = Opt.AutoPlay == "true"? "AutoPlay": ""; // AUTOPLAY (True는 자동 재생입니다)
_this.poster = opt.poster; // 비디오 표지, 재생 중에 커버 사진
_this.preload = opt.preload == "true"? "Preload": ""; // preload (true시로드 시작)
_this.loop = opt.loop == "true"? "루프": ""; // 루프 재생 (루프 재생이 될 때)
var str = "<video id = 'playvideo'컨트롤"; // 세트 속성의 값에 따라 비디오 제어 철자
str + = "width = ' + _this.width +"'height = ' + _this.height + "" + _this.autoplay + "" + _this.preload + "" + _this.loop + ";
if (typeof (_this.poster)! = "undefined") {
str + = "poster = '" + _this.poster + "'>";
} 또 다른 {
str += ">";
}
str + = "<소스 src = '" + _this.src + "' />";
str += "</video>";
this.elemt.innerhtml = str; // 삽입 할 객체에 str을 넣습니다
}
PlayVideo ({
// 모든 매개 변수, ELEMT 및 SRC는 요구 사항에 따라 다른 매개 변수를 작성해야합니다.
// Elemt는 재생 컨트롤에 삽입 될 컨테이너, SRC는 비디오 파일 주소이며, 예압은 예압이며, 자동 재생 페이지가 들어 오면 자동으로 재생됩니다.
// 포스터는 재생하기 전에 폐색 된 그림이며, 루프는 루프를 재생하는지, 너비 및 heigth는 기본적으로 100%입니다.
elemt : document.getElementById ( "divvideo"),
SRC : "3.mp4",
예압 : "참",
AutoPlay : "True",
포스터 : "",
루프 : "참",
너비: "",
키:""
});
</스크립트>
</body>
</html>