mui 視頻播放代碼
注意:需要在配置里加入 視頻播放器SDK 才能使用MUI原生播放器
mui 視頻播放代碼分享
<!DOCTYPE html>
<html>
? ? <head>
? ? ? ? <meta charset="utf-8">
? ? ? ? <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
? ? ? ? <title></title>
? ? ? ? <script src="js/mui.min.js"></script>
? ? ? ? <link href="css/mui.min.css" rel="stylesheet" />
? ? ? ? <script type="text/javascript" charset="utf-8">
? ? ? ? ? ? mui.init();
? ? ? ? ? ? document.addEventListener("plusready", function() { //"plusready"事件觸發(fā)時(shí)執(zhí)行plus對(duì)象的方法
? ? ? ? ? ? ? ? judgePlatform();
? ? ? ? ? ? }, false);
? ? ? ? ? ? function judgePlatform() {
? ? ? ? ? ? ? ? var plat = "";
? ? ? ? ? ? ? ? switch(plus.os.name) {
? ? ? ? ? ? ? ? ? ? case "Android":
? ? ? ? ? ? ? ? ? ? ? ? // Android平臺(tái): plus.android.*
? ? ? ? ? ? ? ? ? ? ? ? plat = "android";
? ? ? ? ? ? ? ? ? ? ? ? var btn = document.getElementById("playBtn");
? ? ? ? ? ? ? ? ? ? ? ? //監(jiān)聽點(diǎn)擊事件
? ? ? ? ? ? ? ? ? ? ? ? btn.addEventListener("tap", function() {
? ? ? ? ? ? ? ? ? ? ? ? ? ? console.log("-------開始播放--------");
? ? ? ? ? ? ? ? ? ? ? ? ? ? playVideo();
? ? ? ? ? ? ? ? ? ? ? ? });
? ? ? ? ? ? ? ? ? ? ? ? //觸發(fā)submit按鈕的點(diǎn)擊事件
//? ? ? ? ? ? ? ? ? ? ? ? mui.trigger(btn, 'tap');
? ? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? ? ? case "iOS":
? ? ? ? ? ? ? ? ? ? ? ? // iOS平臺(tái): plus.ios.*
? ? ? ? ? ? ? ? ? ? ? ? plat = "ios";
? ? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? ? ? default:
? ? ? ? ? ? ? ? ? ? ? ? // 其它平臺(tái)
? ? ? ? ? ? ? ? ? ? ? ? plat = "other";
? ? ? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? document.getElementById("msg").innerHTML ="當(dāng)前平臺(tái)是:"+plat;
? ? ? ? ? ? }
? ? ? ? ? ? function playVideo() {
? ? ? ? ? ? ? ? var Intent = plus.android.importClass("android.content.Intent");
? ? ? ? ? ? ? ? var Uri = plus.android.importClass("android.net.Uri");
? ? ? ? ? ? ? ? var main = plus.android.runtimeMainActivity();
? ? ? ? ? ? ? ? var intent = new Intent(Intent.ACTION_VIEW);
? ? ? ? ? ? ? ? var uri = Uri.parse("http://wx.aonestep.com/video/t001.webm");
? ? ? ? ? ? ? ? intent.setDataAndType(uri, "video/*");
? ? ? ? ? ? ? ? main.startActivity(intent);
? ? ? ? ? ? }
? ? ? ? </script>
? ? </head>
<style type="text/css">
? ? div{
? ? ? ? text-align: center;
? ? ? ? margin-top: 7rem;
? ? }
</style>
? ? <body>
? ? ? ? <div id="msg"></div>
? ? ? ? <div id="">
? ? <button type="button" class="mui-btn mui-btn-blue" id="playBtn">播放</button>
? ? ? ? </div>
? ? </body>
</html>