コードコピーは次のとおりです。
<!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>
// JSのレベルは限られているため、気に入らない場合は批判しないでください。大丈夫だと思ってください。ビデオはHTML5の新しいコントロールです。あなたはそれをチェックすることができます。
<script type = "text/javascript">
// MP4は、iOSとAndroidによって一般的にサポートされる形式です
function playvideo(opt){
if(typeof(opt)== "undefined"){
アラート(「必要なパラメーターに合格してください!」);
戻る;
}
if(typeof(opt.elemt)== "未定義"){
アラート(「プレーヤーが挿入するオブジェクトを指定してください!」);
戻る;
}
if(typeof(opt.src)== "未定義"){
アラート(「ビデオを再生するパスを指定してください!」);
戻る;
}
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(trueは自動再生です)
_this.poster = opt.poster; //ビデオカバー、再生中に写真をカバーします
_this.preload = opt.preload == "true"? 「プリロード」: ""; // Preload(Trueの場合は読み込みを開始)
_this.loop = opt.loop == "true"? 「ループ」: ""; //ループプレイ(ループが真の場合に再生)
var str = "<video id = 'playvideo' controls"; //セット属性の値に基づいてビデオコントロールを綴る
str + = "width = '" + _this.width + "' height = '" + _this.height + "'" + _this.autoplay + "" + _this.preload + "" + _this.loop + "";
if(typeof(_this.poster)!= "未定"){
str + = "poster = '" + _this.poster + "'>";
} それ以外 {
str += ">";
}
str + = "<source src = '" + _this.src + "' />";
str += "</video>";
this.elemt.innerhtml = str; //挿入するオブジェクトにstrを入れます
}
playvideo({
//要件に応じて、他のパラメーターを入力するには、すべてのパラメーター、ELEMTおよびSRCが必要です
// ELEMTは再生コントロールに挿入されるコンテナであり、SRCはビデオファイルアドレスであり、プリロードはプリロードであり、自動再生ページが入力された場合、自動的に再生されます
//ポスターは再生の前に閉塞された画像です、ループはループを再生するかどうか、幅、および将来はデフォルトで100%です
ELEMT:document.getElementById( "divvideo")、
SRC: "3.mp4"、
プリロード:「本当」、
オートプレイ:「本当」、
ポスター: ""、
ループ:「本当」、
幅: ""、
身長:""
});
</script>
</body>
</html>