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

Skip to content

Commit d3f413a

Browse files
committed
[CHG]修复对讲参数获取异常问题
1 parent 74dc019 commit d3f413a

File tree

1 file changed

+68
-87
lines changed

1 file changed

+68
-87
lines changed

ezuikit.js

Lines changed: 68 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -99,50 +99,31 @@
9999
var EZUIKitPlayer = function (params) {
100100
var _this = this;
101101
console.log("params", params);
102-
this.opt = {
103-
id: params.id,
104-
apiDomain: 'https://open.ys7.com/api/lapp/live/talk/url',
105-
filePath: 'https://open.ys7.com/assets/ezuikit_v2.6.4',
106-
accessToken: '',
107-
url: '',
108-
deviceSerial: '',
109-
channelNo: '',
110-
talkLink: '',
111-
rtcUrl: '',
112-
ttsUrl: '',
113-
stream: '',
114-
// 对讲插件依赖
115-
isReliesReady: false,
116-
template: 'simple',
117-
plugin: [], // 加载插件,talk-对讲
118-
audio: 1,// 声音id 0-不开启 1-开启
119-
autoplay: 1,
120-
}
121102
if (params.id) {
122-
this.opt.id = params.id;
103+
EZUIKit.opt.id = params.id;
123104
}
124105
if (params.accessToken) {
125-
this.opt.accessToken = params.accessToken;
106+
EZUIKit.opt.accessToken = params.accessToken;
126107
}
127108
if (typeof params.audio !== 'undefined') {
128-
this.opt.audio = params.audio;
109+
EZUIKit.opt.audio = params.audio;
129110
}
130111
if (params.url) {
131-
this.opt.url = params.url;
132-
this.opt.deviceSerial = params.url.split("/")[3];
133-
this.opt.channelNo = params.url.split("/")[4].split(".")[0];
112+
EZUIKit.opt.url = params.url;
113+
EZUIKit.opt.deviceSerial = params.url.split("/")[3];
114+
EZUIKit.opt.channelNo = params.url.split("/")[4].split(".")[0];
134115
}
135116
if (typeof params.template !== 'undefined') {
136-
this.opt.template = params.template;
117+
EZUIKit.opt.template = params.template;
137118
}
138119
if (params.plugin) {
139-
this.opt.plugin = params.plugin;
120+
EZUIKit.opt.plugin = params.plugin;
140121
}
141122
if (typeof params.autoplay !== 'undefined') {
142-
this.opt.autoplay = params.autoplay ? 1 : 0;
123+
EZUIKit.opt.autoplay = params.autoplay ? 1 : 0;
143124
}
144125

145-
let id = this.opt.id;
126+
let id = EZUIKit.opt.id;
146127
var domElement = document.getElementById(id);
147128
// 间隙
148129
domElement.style.fontSize = 0;
@@ -151,16 +132,16 @@
151132
*/
152133
var iframe = document.createElement('iframe');
153134
function matchIframeUrl() {
154-
switch (_this.opt.template) {
135+
switch (EZUIKit.opt.template) {
155136
case 'simple':
156-
return domain + "/ezopen/h5/iframe?url=" + _this.opt.url + "&autoplay=" + _this.opt.autoplay + "&audio=" + _this.opt.audio + "&accessToken=" + params.accessToken + "&templete=0";
157-
// return "https://open.ys7.com/ezopen/h5/iframe?url=" + _this.opt.url + "&autoplay=" + _this.opt.autoplay + "&audio=" + _this.opt.audio + "&accessToken=" + params.accessToken + "&templete=0";
137+
return domain + "/ezopen/h5/iframe?url=" + EZUIKit.opt.url + "&autoplay=" + EZUIKit.opt.autoplay + "&audio=" + EZUIKit.opt.audio + "&accessToken=" + params.accessToken + "&templete=0";
138+
// return "https://open.ys7.com/ezopen/h5/iframe?url=" + EZUIKit.opt.url + "&autoplay=" + EZUIKit.opt.autoplay + "&audio=" + EZUIKit.opt.audio + "&accessToken=" + params.accessToken + "&templete=0";
158139
case 'standard':
159-
return domain + "/ezopen/h5/iframe?url=" + _this.opt.url + "&autoplay=" + _this.opt.autoplay + "&audio=" + _this.opt.audio + "&accessToken=" + params.accessToken + "&templete=1";
140+
return domain + "/ezopen/h5/iframe?url=" + EZUIKit.opt.url + "&autoplay=" + EZUIKit.opt.autoplay + "&audio=" + EZUIKit.opt.audio + "&accessToken=" + params.accessToken + "&templete=1";
160141
case 'security':
161-
return domain + "/ezopen/h5/iframe_se?url=" + _this.opt.url + "&autoplay=" + _this.opt.autoplay + "&audio=" + _this.opt.audio + "&accessToken=" + params.accessToken + "&templete=0";
142+
return domain + "/ezopen/h5/iframe_se?url=" + EZUIKit.opt.url + "&autoplay=" + EZUIKit.opt.autoplay + "&audio=" + EZUIKit.opt.audio + "&accessToken=" + params.accessToken + "&templete=0";
162143
default:
163-
return domain + "/ezopen/h5/iframe?url=" + _this.opt.url + "&autoplay=" + _this.opt.autoplay + "&audio=" + _this.opt.audio + "&accessToken=" + params.accessToken + "&templete=0";
144+
return domain + "/ezopen/h5/iframe?url=" + EZUIKit.opt.url + "&autoplay=" + EZUIKit.opt.autoplay + "&audio=" + EZUIKit.opt.audio + "&accessToken=" + params.accessToken + "&templete=0";
164145
}
165146
}
166147
iframe.src = matchIframeUrl();
@@ -182,9 +163,9 @@
182163
iframe.setAttribute("frameborder", 0)
183164
console.log("iframe", iframe)
184165
domElement.appendChild(iframe)
185-
var jqueryJS = _this.opt.filePath + '/js/jquery.js';
166+
var jqueryJS = EZUIKit.opt.filePath + '/js/jquery.js';
186167
var layerJs = 'https://open.ys7.com/assets/layer/layer.js';
187-
var recoderCSS = _this.opt.filePath + '/npm/css/recoder.css';
168+
var recoderCSS = EZUIKit.opt.filePath + '/npm/css/recoder.css';
188169
addCss(recoderCSS, function () {
189170

190171
})
@@ -306,7 +287,7 @@
306287
hdModule: false,
307288
fullScreenModule: false,
308289
}
309-
var template = _this.opt.template;
290+
var template = EZUIKit.opt.template;
310291
switch (template) {
311292
case 'simple':
312293
if (params.footer && params.footer instanceof Array) {
@@ -354,7 +335,7 @@
354335
saveModule: false,
355336
zoomModule: false,
356337
}
357-
var template = _this.opt.template;
338+
var template = EZUIKit.opt.template;
358339
switch (template) {
359340
case 'simple':
360341
if (params.header && params.header instanceof Array) {
@@ -382,16 +363,16 @@
382363
}
383364
return result;
384365
}
385-
if (matchFooterOpt().footerContainer || _this.opt.plugin.indexOf('talk') !== -1) {
386-
var recoderCSS = _this.opt.filePath + '/npm/css/recoder.css';
387-
var recoderJs = _this.opt.filePath + '/npm/js/recoder.js';
388-
var recorderJs = _this.opt.filePath + '/recorder.js';
366+
if (matchFooterOpt().footerContainer || EZUIKit.opt.plugin.indexOf('talk') !== -1) {
367+
var recoderCSS = EZUIKit.opt.filePath + '/npm/css/recoder.css';
368+
var recoderJs = EZUIKit.opt.filePath + '/npm/js/recoder.js';
369+
var recorderJs = EZUIKit.opt.filePath + '/recorder.js';
389370
// addCss()
390371
addCss(recoderCSS, function () {
391372
addJs(recoderJs, function () {
392373
addJs(recorderJs, function () {
393374
// 对讲模块
394-
if (_this.opt.plugin.indexOf('talk') !== -1 || matchFooterOpt().talkModule) {
375+
if (EZUIKit.opt.plugin.indexOf('talk') !== -1 || matchFooterOpt().talkModule) {
395376
function apiSuccess(data) {
396377
console.log("data", data);
397378
if (data.code == 200) {
@@ -402,17 +383,17 @@
402383
if (rtcTrunk.indexOf("ws") === -1) {
403384
rtcTrunk = rtcTrunk.replace("https", "wss").replace("rtcgw", "rtcgw-ws");
404385
}
405-
_this.opt.rtcUrl = rtcTrunk;
406-
_this.opt.ttsUrl = "tts://" + apiResult.ttsUrl;
407-
var talk = "talk://" + _this.opt.deviceSerial + ":0:" + _this.opt.channelNo + ":cas.ys7.com:6500";
408-
_this.opt.talkLink = _this.opt.ttsUrl + "/" + talk;
409-
_this.opt.stream = apiResult.stream;
410-
console.log("_this.opt", _this.opt)
386+
EZUIKit.opt.rtcUrl = rtcTrunk;
387+
EZUIKit.opt.ttsUrl = "tts://" + apiResult.ttsUrl;
388+
var talk = "talk://" + EZUIKit.opt.deviceSerial + ":0:" + EZUIKit.opt.channelNo + ":cas.ys7.com:6500";
389+
EZUIKit.opt.talkLink = EZUIKit.opt.ttsUrl + "/" + talk;
390+
EZUIKit.opt.stream = apiResult.stream;
391+
console.log("EZUIKit.opt", EZUIKit.opt)
411392
// 加载依赖
412-
if (!_this.opt.isReliesReady) {
413-
var adapeterJS = _this.opt.filePath + '/npm/js/adapeter.js';
414-
var janusJS = _this.opt.filePath + '/npm/js/janus.js';
415-
var ttsJS = _this.opt.filePath + '/npm/js/tts.js';
393+
if (!EZUIKit.opt.isReliesReady) {
394+
var adapeterJS = EZUIKit.opt.filePath + '/npm/js/adapeter.js';
395+
var janusJS = EZUIKit.opt.filePath + '/npm/js/janus.js';
396+
var ttsJS = EZUIKit.opt.filePath + '/npm/js/tts.js';
416397
console.log("加载jquery.js");
417398
addJs(adapeterJS, function () {
418399
console.log("加载adapeter.js");
@@ -421,7 +402,7 @@
421402
addJs(ttsJS, function () {
422403
console.log("加载tts.js");
423404
// 文件加载完毕;
424-
_this.opt.isReliesReady = true;
405+
EZUIKit.opt.isReliesReady = true;
425406
})
426407
})
427408
})
@@ -450,12 +431,12 @@
450431

451432
}
452433
request(
453-
_this.opt.apiDomain,
434+
EZUIKit.opt.apiDomain,
454435
'POST',
455436
{
456-
accessToken: _this.opt.accessToken,
457-
deviceSerial: _this.opt.deviceSerial,
458-
channelNo: _this.opt.channelNo
437+
accessToken: EZUIKit.opt.accessToken,
438+
deviceSerial: EZUIKit.opt.deviceSerial,
439+
channelNo: EZUIKit.opt.channelNo
459440
},
460441
'',
461442
apiSuccess,
@@ -476,17 +457,17 @@
476457
// 高清-标清切换
477458
var hdDom = document.createElement('span');
478459
hdDom.setAttribute('id', 'video-hd');
479-
hdDom.innerHTML = _this.opt.url.indexOf('.hd') === -1 ? '标清' : '高清';
460+
hdDom.innerHTML = EZUIKit.opt.url.indexOf('.hd') === -1 ? '标清' : '高清';
480461
hdDom.onclick = function () {
481462
// 停止
482463
_this.stop();
483-
if (_this.opt.url.indexOf('.hd') === -1) {
484-
_this.opt.url = _this.opt.url.replace('.live', '.hd.live');
485-
hdDom.innerHTML = _this.opt.url.indexOf('.hd') === -1 ? '标清' : '高清';
464+
if (EZUIKit.opt.url.indexOf('.hd') === -1) {
465+
EZUIKit.opt.url = EZUIKit.opt.url.replace('.live', '.hd.live');
466+
hdDom.innerHTML = EZUIKit.opt.url.indexOf('.hd') === -1 ? '标清' : '高清';
486467
} else {
487-
_this.opt.url = _this.opt.url.replace('.hd.live', '.live')
468+
EZUIKit.opt.url = EZUIKit.opt.url.replace('.hd.live', '.live')
488469
}
489-
iframe.src = "https://open.ys7.com/ezopen/h5/iframe?url=" + _this.opt.url.replace('.hd.live', '.live') + "&autoplay=1&audio=" + _this.opt.audio + "&accessToken=" + _this.opt.accessToken + "&templete=" + 0;
470+
iframe.src = "https://open.ys7.com/ezopen/h5/iframe?url=" + EZUIKit.opt.url.replace('.hd.live', '.live') + "&autoplay=1&audio=" + EZUIKit.opt.audio + "&accessToken=" + EZUIKit.opt.accessToken + "&templete=" + 0;
490471
}
491472
rightContros.appendChild(hdDom);
492473
}
@@ -519,7 +500,7 @@
519500
rightContros.appendChild(closeSoundDOM);
520501
}
521502
// 根据当前音频配置展示
522-
if (_this.opt.audio == 1) {
503+
if (EZUIKit.opt.audio == 1) {
523504
closeSoundDOM.setAttribute('class', '');
524505
} else {
525506
openSoundDOM.setAttribute('class', '');
@@ -686,7 +667,7 @@
686667
'https://open.ys7.com/api/lapp/voice/query',
687668
'POST',
688669
{
689-
accessToken: _this.opt.accessToken,
670+
accessToken: EZUIKit.opt.accessToken,
690671
pageStart: page,
691672
pageSize: EZUIKit.state.pageSize,
692673
default: EZUIKit.state.fetchDefaultList ? 'true' : 'false'
@@ -742,9 +723,9 @@
742723
'https://open.ys7.com/api/lapp/voice/send',
743724
'POST',
744725
{
745-
accessToken: _this.opt.accessToken,
746-
deviceSerial: _this.opt.deviceSerial,
747-
channelNo: _this.opt.channelNo,
726+
accessToken: EZUIKit.opt.accessToken,
727+
deviceSerial: EZUIKit.opt.deviceSerial,
728+
channelNo: EZUIKit.opt.channelNo,
748729
fileUrl: voiceUrl,
749730
},
750731
'',
@@ -902,9 +883,9 @@
902883
countTime('sub', EZUIKit.state.recodeTime + 2); // 延时
903884
var formdata = new FormData(); // form 表单 {key:value}
904885
formdata.append("voiceFile", wav_file); // form input type="file"
905-
formdata.append("accessToken", _this.opt.accessToken);
906-
formdata.append("deviceSerial", _this.opt.deviceSerial);
907-
formdata.append("channelNo", _this.opt.channelNo);
886+
formdata.append("accessToken", EZUIKit.opt.accessToken);
887+
formdata.append("deviceSerial", EZUIKit.opt.deviceSerial);
888+
formdata.append("channelNo", EZUIKit.opt.channelNo);
908889
// padding = true;
909890

910891
function apiSuccess(data) {
@@ -928,9 +909,9 @@
928909
'POST',
929910
{
930911
voiceFile: wav_file,
931-
accessToken: _this.opt.accessToken,
932-
deviceSerial: _this.opt.deviceSerial,
933-
channelNo: _this.opt.channelNo,
912+
accessToken: EZUIKit.opt.accessToken,
913+
deviceSerial: EZUIKit.opt.deviceSerial,
914+
channelNo: EZUIKit.opt.channelNo,
934915
},
935916
'',
936917
apiSuccess,
@@ -1097,57 +1078,57 @@
10971078

10981079
// 播放相关API
10991080
EZUIKitPlayer.prototype.play = function () {
1100-
var id = 'EZUIKitPlayer-' + this.opt.id;
1081+
var id = 'EZUIKitPlayer-' + EZUIKit.opt.id;
11011082
var player = document.getElementById(id).contentWindow;
11021083
player.postMessage("play", domain + "/ezopen/h5/iframe")
11031084
}
11041085
EZUIKitPlayer.prototype.stop = function () {
1105-
var id = 'EZUIKitPlayer-' + this.opt.id;
1086+
var id = 'EZUIKitPlayer-' + EZUIKit.opt.id;
11061087
var player = document.getElementById(id).contentWindow;
11071088
player.postMessage("stop", domain + "/ezopen/h5/iframe")
11081089
}
11091090
EZUIKitPlayer.prototype.openSound = function () {
1110-
var id = 'EZUIKitPlayer-' + this.opt.id;
1091+
var id = 'EZUIKitPlayer-' + EZUIKit.opt.id;
11111092
var player = document.getElementById(id).contentWindow;
11121093
player.postMessage("openSound", domain + "/ezopen/h5/iframe");
11131094
}
11141095
EZUIKitPlayer.prototype.closeSound = function () {
1115-
var id = 'EZUIKitPlayer-' + this.opt.id;
1096+
var id = 'EZUIKitPlayer-' + EZUIKit.opt.id;
11161097
var player = document.getElementById(id).contentWindow;
11171098
player.postMessage("closeSound", domain + "/ezopen/h5/iframe")
11181099
}
11191100
EZUIKitPlayer.prototype.startSave = function () {
1120-
var id = 'EZUIKitPlayer-' + this.opt.id;
1101+
var id = 'EZUIKitPlayer-' + EZUIKit.opt.id;
11211102
var player = document.getElementById(id).contentWindow;
11221103
player.postMessage("startSave", domain + "/ezopen/h5/iframe")
11231104
}
11241105
EZUIKitPlayer.prototype.stopSave = function () {
1125-
var id = 'EZUIKitPlayer-' + this.opt.id;
1106+
var id = 'EZUIKitPlayer-' + EZUIKit.opt.id;
11261107
var player = document.getElementById(id).contentWindow;
11271108
player.postMessage("stopSave", domain + "/ezopen/h5/iframe")
11281109
}
11291110
EZUIKitPlayer.prototype.fullScreen = function () {
1130-
var id = 'EZUIKitPlayer-' + this.opt.id;
1111+
var id = 'EZUIKitPlayer-' + EZUIKit.opt.id;
11311112
var player = document.getElementById(id).contentWindow;
11321113
player.postMessage("fullScreen", domain + "/ezopen/h5/iframe")
11331114
}
11341115
EZUIKitPlayer.prototype.capturePicture = function () {
1135-
var id = 'EZUIKitPlayer-' + this.opt.id;
1116+
var id = 'EZUIKitPlayer-' + EZUIKit.opt.id;
11361117
var player = document.getElementById(id).contentWindow;
11371118
player.postMessage("capturePicture", domain + "/ezopen/h5/iframe")
11381119
}
11391120
EZUIKitPlayer.prototype.enableZoom = function () {
1140-
var id = 'EZUIKitPlayer-' + this.opt.id;
1121+
var id = 'EZUIKitPlayer-' + EZUIKit.opt.id;
11411122
var player = document.getElementById(id).contentWindow;
11421123
player.postMessage("enableZoom", domain + "/ezopen/h5/iframe")
11431124
}
11441125
EZUIKitPlayer.prototype.closeZoom = function () {
1145-
var id = 'EZUIKitPlayer-' + this.opt.id;
1126+
var id = 'EZUIKitPlayer-' + EZUIKit.opt.id;
11461127
var player = document.getElementById(id).contentWindow;
11471128
player.postMessage("closeZoom", domain + "/ezopen/h5/iframe")
11481129
}
11491130
EZUIKitPlayer.prototype.getOSDTime = function () {
1150-
var id = 'EZUIKitPlayer-' + this.opt.id;
1131+
var id = 'EZUIKitPlayer-' + EZUIKit.opt.id;
11511132
var player = document.getElementById(id).contentWindow;
11521133
player.postMessage("getOSDTime", domain + "/ezopen/h5/iframe")
11531134
}

0 commit comments

Comments
 (0)