Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 35cc6e1

Browse files
committed
[CHG]优化高清标清切换逻辑,不需要重新加载解码库
1 parent 744db6e commit 35cc6e1

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

demos/base-demo/ezuikit.js

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
audio: 1,
113113
// 声音id 0-不开启 1-开启
114114
autoplay: 1,
115+
videoLoading: false,
115116
},
116117
state: {
117118
countTimer: undefined,
@@ -161,6 +162,7 @@
161162
autoplay: 1,
162163
fullScreenStatus: 0,
163164
bSupporDoubleClickFull: true,
165+
videoLoading: false,
164166
};
165167
this.params = params;
166168

@@ -568,16 +570,28 @@
568570

569571
hdDom.onclick = function () {
570572
// 停止
571-
_this.stop();
572-
573-
if (_this.opt.url.indexOf('.hd') === -1) {
574-
_this.opt.url = _this.opt.url.replace('.live', '.hd.live');
575-
hdDom.innerHTML = _this.opt.url.indexOf('.hd') === -1 ? '标清' : '高清';
576-
} else {
577-
_this.opt.url = _this.opt.url.replace('.hd.live', '.live');
578-
}
579-
580-
iframe.src = domain +"/ezopen/h5/iframe?url=" + _this.opt.url.replace('.hd.live', '.live') + "&autoplay=1&audio=" + _this.opt.audio + "&accessToken=" + _this.opt.accessToken + "&templete=" + 0;
573+
if(_this.opt.videoLoading){
574+
layer.msg("视频加载中,请稍后");
575+
return false;
576+
}else {
577+
var stopPromise = _this.stop();
578+
_this.opt.videoLoading = true;
579+
stopPromise.then((data)=>{
580+
_this.opt.videoLoading = false;
581+
if (_this.opt.url.indexOf('.hd') === -1) {
582+
_this.opt.url = _this.opt.url.replace('.live', '.hd.live');
583+
hdDom.innerHTML = _this.opt.url.indexOf('.hd') === -1 ? '标清' : '高清';
584+
} else {
585+
_this.opt.url = _this.opt.url.replace('.hd.live', '.live');
586+
hdDom.innerHTML = _this.opt.url.indexOf('.hd') === -1 ? '标清' : '高清';
587+
}
588+
_this.play(_this.opt.url)
589+
})
590+
.catch((error)=>{
591+
console.log("error",error)
592+
})
593+
}
594+
//iframe.src = domain +"/ezopen/h5/iframe?url=" + _this.opt.url.replace('.hd.live', '.live') + "&autoplay=1&audio=" + _this.opt.audio + "&accessToken=" + _this.opt.accessToken + "&templete=" + 0;
581595
};
582596

583597
rightContros.appendChild(hdDom);
@@ -1214,10 +1228,14 @@
12141228
url: this.opt.url
12151229
}, domain + "/ezopen/h5/iframe");
12161230
var _this = this;
1231+
this.opt.videoLoading = true;
12171232
var promise = new Promise(function(resolve,reject) {
12181233
window.addEventListener("message", function (event) {
12191234
var playId = _this.opt.id;
12201235
if (playId == event.data.id && event.data.type === 'handleSuccess') {
1236+
setTimeout(()=>{
1237+
_this.opt.videoLoading = false;
1238+
},1000)
12211239
resolve(event.data);
12221240
}
12231241
});

0 commit comments

Comments
 (0)