ezuikit-js 0.4.4 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/demos/base-demo/ezuikit.js +497 -177
- package/ezuikit.js +850 -110
- package/package.json +1 -1
package/ezuikit.js
CHANGED
|
@@ -14,13 +14,17 @@ class Core {
|
|
|
14
14
|
Date.prototype.Format = function (fmt) { var o = { "M+": this.getMonth() + 1, "d+": this.getDate(), "h+": this.getHours(), "m+": this.getMinutes(), "s+": this.getSeconds(), "q+": Math.floor((this.getMonth() + 3) / 3), "S": this.getMilliseconds() }; if (/(y+)/.test(fmt)) { fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); } for (var k in o) { if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); } return fmt };
|
|
15
15
|
|
|
16
16
|
// 加载js
|
|
17
|
-
const addJs = (filepath, callback) => {
|
|
17
|
+
const addJs = (filepath, callback, isReadyFun) => {
|
|
18
18
|
var headerScript = document.getElementsByTagName('head')[0].getElementsByTagName("script");
|
|
19
19
|
var isReady = false;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
if(isReadyFun) {
|
|
21
|
+
isReady = isReadyFun();
|
|
22
|
+
} else {
|
|
23
|
+
for (var i = 0; i < headerScript.length; i++) {
|
|
24
|
+
if (headerScript[i].getAttribute("src") == filepath) {
|
|
25
|
+
isReady = true;
|
|
26
|
+
callback();
|
|
27
|
+
}
|
|
24
28
|
}
|
|
25
29
|
}
|
|
26
30
|
if (!isReady) {
|
|
@@ -201,7 +205,7 @@ const request = (url, method, params, header, success, error) => {
|
|
|
201
205
|
|
|
202
206
|
class HLS {
|
|
203
207
|
constructor(videoId, url) {
|
|
204
|
-
addJs("https://
|
|
208
|
+
addJs("https://open.ys7.com/sdk/js/2.0/js/hls.min.js", () => {
|
|
205
209
|
console.log("加载hls.min.js成功", window.Hls);
|
|
206
210
|
console.log("isSupportHls", window.Hls.isSupported());
|
|
207
211
|
if (window.Hls.isSupported()) {
|
|
@@ -24067,7 +24071,8 @@ C11.4,16.3,11,16.6,10.6,16.6z" />
|
|
|
24067
24071
|
}
|
|
24068
24072
|
this.timer = setInterval(() => {
|
|
24069
24073
|
var getOSDTimePromise = this.jSPlugin.getOSDTime();
|
|
24070
|
-
getOSDTimePromise.then((
|
|
24074
|
+
getOSDTimePromise.then((data) => {
|
|
24075
|
+
var v = data.data;
|
|
24071
24076
|
if (v === -1) {
|
|
24072
24077
|
console.log("获取播放时间错误");
|
|
24073
24078
|
} else {
|
|
@@ -26106,12 +26111,19 @@ class Theme {
|
|
|
26106
26111
|
this.initThemeData();
|
|
26107
26112
|
this.renderThemeData();
|
|
26108
26113
|
break;
|
|
26114
|
+
case 'themeData':
|
|
26115
|
+
this.themeData = this.jSPlugin.params.themeData;
|
|
26116
|
+
this.initThemeData();
|
|
26117
|
+
this.renderThemeData();
|
|
26109
26118
|
default:
|
|
26110
26119
|
this.fetchThemeData(this.jSPlugin.themeId);
|
|
26111
26120
|
break;
|
|
26112
26121
|
}
|
|
26113
26122
|
}
|
|
26114
|
-
|
|
26123
|
+
var isNeedRenderTimeLine = lodash.findIndex(this.themeData.header.btnList, (v)=>{
|
|
26124
|
+
return (v.iconId === 'cloudRec' && v.isrender === 1) || (v.iconId === 'rec' && v.isrender === 1) ;
|
|
26125
|
+
}) >= 0 || (this.isMobile &&matchEzopenUrl(jSPlugin.url).type.indexOf('rec') !== -1);
|
|
26126
|
+
if (isNeedRenderTimeLine) {
|
|
26115
26127
|
if (this.isMobile) {
|
|
26116
26128
|
this.Rec = new MobileRec(jSPlugin);
|
|
26117
26129
|
} else {
|
|
@@ -26121,7 +26133,7 @@ class Theme {
|
|
|
26121
26133
|
if (!this.jSPlugin.Talk) {
|
|
26122
26134
|
this.jSPlugin.Talk = new Talk(this.jSPlugin);
|
|
26123
26135
|
}
|
|
26124
|
-
if (
|
|
26136
|
+
if (matchEzopenUrl(jSPlugin.url).type === 'live') {
|
|
26125
26137
|
if (this.isMobile) {
|
|
26126
26138
|
this.MobilePtz = new MobilePtz(jSPlugin);
|
|
26127
26139
|
this.Ptz = new Ptz(jSPlugin);
|
|
@@ -26212,7 +26224,7 @@ class Theme {
|
|
|
26212
26224
|
}
|
|
26213
26225
|
break;
|
|
26214
26226
|
case 'sound':
|
|
26215
|
-
if (`${this.jSPlugin.id}-sound`) {
|
|
26227
|
+
if (document.getElementById(`${this.jSPlugin.id}-sound`)) {
|
|
26216
26228
|
if (options[item]) {
|
|
26217
26229
|
document.getElementById(`${this.jSPlugin.id}-sound-content`).children[0].children[1].style = "display:inline-block";
|
|
26218
26230
|
document.getElementById(`${this.jSPlugin.id}-sound-content`).children[0].children[0].style = "display:none";
|
|
@@ -27002,6 +27014,43 @@ class Theme {
|
|
|
27002
27014
|
}
|
|
27003
27015
|
}
|
|
27004
27016
|
|
|
27017
|
+
class Monitor {
|
|
27018
|
+
constructor(params) {
|
|
27019
|
+
this.params = params;
|
|
27020
|
+
this.state = {
|
|
27021
|
+
};
|
|
27022
|
+
}
|
|
27023
|
+
dclog(dclogObj) {
|
|
27024
|
+
const { params } = this;
|
|
27025
|
+
var url = "https://log.ys7.com/statistics.do?";
|
|
27026
|
+
if(params.env) {
|
|
27027
|
+
switch(params.env){
|
|
27028
|
+
case 'test12':
|
|
27029
|
+
url = "https://test12dclog.ys7.com/statistics.do?";
|
|
27030
|
+
break;
|
|
27031
|
+
case 'online':
|
|
27032
|
+
break;
|
|
27033
|
+
default:
|
|
27034
|
+
url = params.env;
|
|
27035
|
+
break;
|
|
27036
|
+
}
|
|
27037
|
+
}
|
|
27038
|
+
var obj = Object.assign({}, { systemName: "open_website_monitor" }, { bn: "ezuikit-js" }, dclogObj, {un:dclogObj.url}, { st: new Date().getTime(), h: window.location.pathname }); // usr_name 更改为un,兼容旧
|
|
27039
|
+
Object.keys(obj).forEach(function(item, index){
|
|
27040
|
+
var value = obj[item];
|
|
27041
|
+
if (typeof (obj[item]) === 'string') {
|
|
27042
|
+
value = obj[item].replace('%', '%25'); // decodeURIComponent 无法解析%
|
|
27043
|
+
}
|
|
27044
|
+
if (typeof (obj[item]) === 'undefined') {
|
|
27045
|
+
return;
|
|
27046
|
+
}
|
|
27047
|
+
url += "".concat(index === 0 ? '' : '&').concat(item, "=").concat(encodeURIComponent(value));
|
|
27048
|
+
});
|
|
27049
|
+
var img = new Image();
|
|
27050
|
+
img.src = url;
|
|
27051
|
+
}
|
|
27052
|
+
}
|
|
27053
|
+
|
|
27005
27054
|
/**
|
|
27006
27055
|
* EZUIKitPlayer for npm
|
|
27007
27056
|
*/
|
|
@@ -27551,6 +27600,8 @@ class Theme {
|
|
|
27551
27600
|
_this.opt.isReliesReady = true;
|
|
27552
27601
|
});
|
|
27553
27602
|
});
|
|
27603
|
+
},()=>{
|
|
27604
|
+
return !!window.adapter;
|
|
27554
27605
|
});
|
|
27555
27606
|
} // 创建DOM
|
|
27556
27607
|
|
|
@@ -28597,13 +28648,638 @@ class Theme {
|
|
|
28597
28648
|
});
|
|
28598
28649
|
var EZUIKitV3$1 = EZUIKitV3;
|
|
28599
28650
|
|
|
28651
|
+
/**
|
|
28652
|
+
* Created by wangweijie5 on 2016/12/16.
|
|
28653
|
+
*/
|
|
28654
|
+
|
|
28655
|
+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
28656
|
+
|
|
28657
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
28658
|
+
|
|
28659
|
+
var __instance = function () {
|
|
28660
|
+
var instance = void 0;
|
|
28661
|
+
return function (newInstance) {
|
|
28662
|
+
if (newInstance) instance = newInstance;
|
|
28663
|
+
return instance;
|
|
28664
|
+
};
|
|
28665
|
+
}();
|
|
28666
|
+
|
|
28667
|
+
(function () {
|
|
28668
|
+
function AudioRenderer() {
|
|
28669
|
+
_classCallCheck(this, AudioRenderer);
|
|
28670
|
+
|
|
28671
|
+
if (__instance()) return __instance();
|
|
28672
|
+
|
|
28673
|
+
// 确保只有单例
|
|
28674
|
+
if (AudioRenderer.unique !== undefined) {
|
|
28675
|
+
return AudioRenderer.unique;
|
|
28676
|
+
}
|
|
28677
|
+
|
|
28678
|
+
AudioRenderer.unique = this;
|
|
28679
|
+
|
|
28680
|
+
this.oAudioContext = null;
|
|
28681
|
+
this.currentVolume = 0.8; // 初始音量
|
|
28682
|
+
this.bSetVolume = false;
|
|
28683
|
+
this.gainNode = null;
|
|
28684
|
+
this.iWndNum = -1; // 窗口号
|
|
28685
|
+
this.mVolumes = new Map(); // 用于存储所有音量
|
|
28686
|
+
|
|
28687
|
+
// Init AudioContext
|
|
28688
|
+
var AudioContext = window.AudioContext || window.webkitAudioContext;
|
|
28689
|
+
this.oAudioContext = new AudioContext();
|
|
28690
|
+
|
|
28691
|
+
this.writeString = function (view, offset, string) {
|
|
28692
|
+
for (var i = 0; i < string.length; i++) {
|
|
28693
|
+
view.setUint8(offset + i, string.charCodeAt(i));
|
|
28694
|
+
}
|
|
28695
|
+
};
|
|
28696
|
+
|
|
28697
|
+
this.setBufferToDataview = function (output, offset, input) {
|
|
28698
|
+
for (var i = 0; i < input.length; i++, offset++) {
|
|
28699
|
+
output.setUint8(offset, input[i]);
|
|
28700
|
+
}
|
|
28701
|
+
};
|
|
28702
|
+
|
|
28703
|
+
__instance(this);
|
|
28704
|
+
}
|
|
28705
|
+
|
|
28706
|
+
/**
|
|
28707
|
+
* @synopsis 音频播放
|
|
28708
|
+
*
|
|
28709
|
+
* @param dataBuf [IN] 音频缓存
|
|
28710
|
+
* @param dataLen [IN] 缓存长度
|
|
28711
|
+
* @param audioInfo [IN] 音频参数
|
|
28712
|
+
*
|
|
28713
|
+
* @returns 状态码
|
|
28714
|
+
*/
|
|
28715
|
+
|
|
28716
|
+
|
|
28717
|
+
_createClass(AudioRenderer, [{
|
|
28718
|
+
key: 'Play',
|
|
28719
|
+
value: function Play(dataBuf, dataLen, audioInfo) {
|
|
28720
|
+
var bufferData = new ArrayBuffer(44 + dataLen);
|
|
28721
|
+
var viewTalk = new DataView(bufferData);
|
|
28722
|
+
var sampleRates = audioInfo.samplesPerSec;
|
|
28723
|
+
var channels = audioInfo.channels;
|
|
28724
|
+
var bitsPerSample = audioInfo.bitsPerSample;
|
|
28725
|
+
|
|
28726
|
+
//console.log("audiorender sampleRates"+sampleRates+"channels:"+channels+"bitsPerSample:"+bitsPerSample);
|
|
28727
|
+
|
|
28728
|
+
/* RIFF identifier */
|
|
28729
|
+
this.writeString(viewTalk, 0, 'RIFF');
|
|
28730
|
+
/* file length */
|
|
28731
|
+
viewTalk.setUint32(4, 32 + dataLen * 2, true);
|
|
28732
|
+
/* RIFF type */
|
|
28733
|
+
this.writeString(viewTalk, 8, 'WAVE');
|
|
28734
|
+
/* format chunk identifier */
|
|
28735
|
+
this.writeString(viewTalk, 12, 'fmt ');
|
|
28736
|
+
/* format chunk length */
|
|
28737
|
+
viewTalk.setUint32(16, 16, true);
|
|
28738
|
+
/* sample format (raw) */
|
|
28739
|
+
viewTalk.setUint16(20, 1, true);
|
|
28740
|
+
/* channel count */
|
|
28741
|
+
viewTalk.setUint16(22, channels, true);
|
|
28742
|
+
/* sample rate */
|
|
28743
|
+
viewTalk.setUint32(24, sampleRates, true);
|
|
28744
|
+
/* byte rate (sample rate * block align) */
|
|
28745
|
+
viewTalk.setUint32(28, sampleRates * 2, true);
|
|
28746
|
+
/* block align (channel count * bytes per sample)/8 */
|
|
28747
|
+
viewTalk.setUint16(32, channels * bitsPerSample / 8, true);
|
|
28748
|
+
/* bits per sample */
|
|
28749
|
+
viewTalk.setUint16(34, bitsPerSample, true);
|
|
28750
|
+
/* data chunk identifier */
|
|
28751
|
+
this.writeString(viewTalk, 36, 'data');
|
|
28752
|
+
/* data chunk length */
|
|
28753
|
+
viewTalk.setUint32(40, dataLen, true);
|
|
28754
|
+
this.setBufferToDataview(viewTalk, 44, dataBuf);
|
|
28755
|
+
|
|
28756
|
+
var self = this;
|
|
28757
|
+
this.oAudioContext.decodeAudioData(viewTalk.buffer, function (buffer) {
|
|
28758
|
+
|
|
28759
|
+
var bufferSource = self.oAudioContext.createBufferSource();
|
|
28760
|
+
if (bufferSource == null) {
|
|
28761
|
+
return -1;
|
|
28762
|
+
}
|
|
28763
|
+
|
|
28764
|
+
bufferSource.buffer = buffer;
|
|
28765
|
+
bufferSource.start(0);
|
|
28766
|
+
|
|
28767
|
+
if (self.gainNode == null || self.bSetVolume) {
|
|
28768
|
+
self.gainNode = self.oAudioContext.createGain();
|
|
28769
|
+
// self.gainNode.gain.value = self.currentVolume;
|
|
28770
|
+
// // self.currentVolume = self.gainNode.gain.value;
|
|
28771
|
+
// self.gainNode.connect(self.oAudioContext.destination);
|
|
28772
|
+
|
|
28773
|
+
self.bSetVolume = false;
|
|
28774
|
+
}
|
|
28775
|
+
|
|
28776
|
+
self.gainNode.gain.value = self.currentVolume;
|
|
28777
|
+
// self.currentVolume = self.gainNode.gain.value;
|
|
28778
|
+
self.gainNode.connect(self.oAudioContext.destination);
|
|
28779
|
+
|
|
28780
|
+
bufferSource.connect(self.gainNode);
|
|
28781
|
+
}, function (e) {
|
|
28782
|
+
console.log("decode error");
|
|
28783
|
+
return -1;
|
|
28784
|
+
});
|
|
28785
|
+
|
|
28786
|
+
return 0;
|
|
28787
|
+
}
|
|
28788
|
+
|
|
28789
|
+
/**
|
|
28790
|
+
* @synopsis 停止播放
|
|
28791
|
+
*
|
|
28792
|
+
* @returns 返回音量
|
|
28793
|
+
*/
|
|
28794
|
+
|
|
28795
|
+
}, {
|
|
28796
|
+
key: 'Stop',
|
|
28797
|
+
value: function Stop() {
|
|
28798
|
+
if (this.gainNode != null) {
|
|
28799
|
+
this.gainNode.disconnect();
|
|
28800
|
+
this.gainNode = null;
|
|
28801
|
+
}
|
|
28802
|
+
|
|
28803
|
+
// this.oAudioContext.close();
|
|
28804
|
+
|
|
28805
|
+
// AudioRenderer.unique = undefined;
|
|
28806
|
+
// __instance() = null;
|
|
28807
|
+
return true;
|
|
28808
|
+
}
|
|
28809
|
+
|
|
28810
|
+
/**
|
|
28811
|
+
* @synopsis 设置音量
|
|
28812
|
+
*
|
|
28813
|
+
* @param iVolume [IN] 音量
|
|
28814
|
+
*
|
|
28815
|
+
* @returns 状态码
|
|
28816
|
+
*/
|
|
28817
|
+
|
|
28818
|
+
}, {
|
|
28819
|
+
key: 'SetVolume',
|
|
28820
|
+
value: function SetVolume(iVolume) {
|
|
28821
|
+
this.bSetVolume = true;
|
|
28822
|
+
this.currentVolume = iVolume;
|
|
28823
|
+
|
|
28824
|
+
// 储存当前窗口设置音量值
|
|
28825
|
+
this.mVolumes.set(this.iWndNum, iVolume);
|
|
28826
|
+
return true;
|
|
28827
|
+
}
|
|
28828
|
+
|
|
28829
|
+
/**
|
|
28830
|
+
* @synopsis 设置窗口号
|
|
28831
|
+
*
|
|
28832
|
+
* @param iWndNum [IN] 窗口号
|
|
28833
|
+
*
|
|
28834
|
+
* @returns 状态码
|
|
28835
|
+
*/
|
|
28836
|
+
|
|
28837
|
+
}, {
|
|
28838
|
+
key: 'SetWndNum',
|
|
28839
|
+
value: function SetWndNum(iWndNum) {
|
|
28840
|
+
this.iWndNum = iWndNum;
|
|
28841
|
+
|
|
28842
|
+
// 获取当前窗口设置音量值
|
|
28843
|
+
var iVolume = this.mVolumes.get(iWndNum);
|
|
28844
|
+
if (iVolume == undefined) {
|
|
28845
|
+
iVolume = 0.8; // 默认音量
|
|
28846
|
+
}
|
|
28847
|
+
this.currentVolume = iVolume;
|
|
28848
|
+
|
|
28849
|
+
return true;
|
|
28850
|
+
}
|
|
28851
|
+
|
|
28852
|
+
/**
|
|
28853
|
+
* @synopsis 获取音量
|
|
28854
|
+
*
|
|
28855
|
+
* @returns 返回音量
|
|
28856
|
+
*/
|
|
28857
|
+
|
|
28858
|
+
}, {
|
|
28859
|
+
key: 'GetVolume',
|
|
28860
|
+
value: function GetVolume() {
|
|
28861
|
+
// 获取当前窗口设置音量值
|
|
28862
|
+
var iVolume = this.mVolumes.get(this.iWndNum);
|
|
28863
|
+
if (iVolume == undefined) {
|
|
28864
|
+
iVolume = 0.8; // 默认音量
|
|
28865
|
+
}
|
|
28866
|
+
|
|
28867
|
+
return iVolume;
|
|
28868
|
+
}
|
|
28869
|
+
}]);
|
|
28870
|
+
window.AudioRenderer = AudioRenderer;
|
|
28871
|
+
return AudioRenderer;
|
|
28872
|
+
})();
|
|
28873
|
+
|
|
28874
|
+
//顶点着色器
|
|
28875
|
+
//attribute修饰符用于声明由浏览器(javascript)传输给顶点着色器的变量值;
|
|
28876
|
+
// vertexPos即我们定义的顶点坐标;
|
|
28877
|
+
// gl_Position是一个内建的传出变量。
|
|
28878
|
+
var vertexYUVShader = [
|
|
28879
|
+
'attribute vec4 vertexPos;',
|
|
28880
|
+
'attribute vec2 texturePos;',
|
|
28881
|
+
'varying vec2 textureCoord;',
|
|
28882
|
+
|
|
28883
|
+
'void main()',
|
|
28884
|
+
'{',
|
|
28885
|
+
'gl_Position = vertexPos;',
|
|
28886
|
+
'textureCoord = texturePos;',
|
|
28887
|
+
'}'
|
|
28888
|
+
].join('\n');
|
|
28889
|
+
//像素着色器(yuv->rgb)
|
|
28890
|
+
var fragmentYUVShader = [
|
|
28891
|
+
'precision highp float;',
|
|
28892
|
+
'varying highp vec2 textureCoord;',
|
|
28893
|
+
'uniform sampler2D ySampler;',
|
|
28894
|
+
'uniform sampler2D uSampler;',
|
|
28895
|
+
'uniform sampler2D vSampler;',
|
|
28896
|
+
'const mat4 YUV2RGB = mat4',
|
|
28897
|
+
'(',
|
|
28898
|
+
'1.1643828125, 0, 1.59602734375, -.87078515625,',
|
|
28899
|
+
'1.1643828125, -.39176171875, -.81296875, .52959375,',
|
|
28900
|
+
'1.1643828125, 2.017234375, 0, -1.081390625,',
|
|
28901
|
+
'0, 0, 0, 1',
|
|
28902
|
+
');',
|
|
28903
|
+
|
|
28904
|
+
'void main(void) {',
|
|
28905
|
+
'highp float y = texture2D(ySampler, textureCoord).r;',
|
|
28906
|
+
'highp float u = texture2D(uSampler, textureCoord).r;',
|
|
28907
|
+
'highp float v = texture2D(vSampler, textureCoord).r;',
|
|
28908
|
+
'gl_FragColor = vec4(y, u, v, 1) * YUV2RGB;',
|
|
28909
|
+
'}'
|
|
28910
|
+
].join('\n');
|
|
28911
|
+
|
|
28912
|
+
(function (root, factory) {
|
|
28913
|
+
// root.SuperRender = factory();
|
|
28914
|
+
window.SuperRender = factory();
|
|
28915
|
+
}(undefined, function () {
|
|
28916
|
+
|
|
28917
|
+
function RenderManager(canvas) {
|
|
28918
|
+
|
|
28919
|
+
this.canvasElement = document.getElementById(canvas);
|
|
28920
|
+
|
|
28921
|
+
this.initContextGL();
|
|
28922
|
+
|
|
28923
|
+
if(this.contextGL) {
|
|
28924
|
+
this.YUVProgram = this.initProgram(vertexYUVShader, fragmentYUVShader);
|
|
28925
|
+
this.initBuffers();
|
|
28926
|
+
this.initTextures();
|
|
28927
|
+
}
|
|
28928
|
+
}
|
|
28929
|
+
/**
|
|
28930
|
+
* 初始化WebGL上下文
|
|
28931
|
+
*/
|
|
28932
|
+
RenderManager.prototype.initContextGL = function() {
|
|
28933
|
+
|
|
28934
|
+
var canvas = this.canvasElement;
|
|
28935
|
+
|
|
28936
|
+
var gl = null;
|
|
28937
|
+
|
|
28938
|
+
try {
|
|
28939
|
+
gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
|
|
28940
|
+
} catch (e) {
|
|
28941
|
+
gl = null;
|
|
28942
|
+
}
|
|
28943
|
+
|
|
28944
|
+
if(!gl || typeof gl.getParameter !== "function") {
|
|
28945
|
+
gl = null;
|
|
28946
|
+
}
|
|
28947
|
+
|
|
28948
|
+
this.contextGL = gl;
|
|
28949
|
+
|
|
28950
|
+
console.log("WebGL1.0");
|
|
28951
|
+
};
|
|
28952
|
+
|
|
28953
|
+
/**
|
|
28954
|
+
* 初始化着色器程序
|
|
28955
|
+
* @param vertexShaderScript 顶点着色器脚本
|
|
28956
|
+
* @param fragmentShaderScript 片段着色器脚本
|
|
28957
|
+
*/
|
|
28958
|
+
RenderManager.prototype.initProgram = function(vertexShaderScript, fragmentShaderScript) {
|
|
28959
|
+
|
|
28960
|
+
var gl = this.contextGL;
|
|
28961
|
+
|
|
28962
|
+
var vertexShader = gl.createShader(gl.VERTEX_SHADER); //创建定点着色器
|
|
28963
|
+
gl.shaderSource(vertexShader, vertexShaderScript);
|
|
28964
|
+
gl.compileShader(vertexShader);
|
|
28965
|
+
if(!gl.getShaderParameter(vertexShader, gl.COMPILE_STATUS)) {
|
|
28966
|
+
console.log('Vertex shader failed to compile: ' + gl.getShaderInfoLog(vertexShader));
|
|
28967
|
+
}
|
|
28968
|
+
|
|
28969
|
+
var fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);
|
|
28970
|
+
gl.shaderSource(fragmentShader, fragmentShaderScript);
|
|
28971
|
+
gl.compileShader(fragmentShader);
|
|
28972
|
+
if(!gl.getShaderParameter(fragmentShader, gl.COMPILE_STATUS)) {
|
|
28973
|
+
console.log('Fragment shader failed to compile: ' + gl.getShaderInfoLog(fragmentShader));
|
|
28974
|
+
}
|
|
28975
|
+
|
|
28976
|
+
var program = gl.createProgram();
|
|
28977
|
+
gl.attachShader(program, vertexShader);
|
|
28978
|
+
gl.attachShader(program, fragmentShader);
|
|
28979
|
+
gl.linkProgram(program);
|
|
28980
|
+
if(!gl.getProgramParameter(program, gl.LINK_STATUS)) {
|
|
28981
|
+
console.log('Program failed to compile: ' + gl.getProgramInfoLog(program));
|
|
28982
|
+
}
|
|
28983
|
+
|
|
28984
|
+
gl.deleteShader(vertexShader);
|
|
28985
|
+
gl.deleteShader(fragmentShader);
|
|
28986
|
+
|
|
28987
|
+
return program;
|
|
28988
|
+
};
|
|
28989
|
+
|
|
28990
|
+
/**
|
|
28991
|
+
* 初始化数据缓存
|
|
28992
|
+
*/
|
|
28993
|
+
RenderManager.prototype.initBuffers = function() {
|
|
28994
|
+
|
|
28995
|
+
var gl = this.contextGL;
|
|
28996
|
+
|
|
28997
|
+
var vertexPosBuffer = gl.createBuffer();
|
|
28998
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, vertexPosBuffer);
|
|
28999
|
+
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([1, 1, -1, 1, 1, -1, -1, -1]), gl.STATIC_DRAW);
|
|
29000
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
29001
|
+
|
|
29002
|
+
var texturePosBuffer = gl.createBuffer();
|
|
29003
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, texturePosBuffer);
|
|
29004
|
+
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([1, 0, 0, 0, 1, 1, 0, 1]), gl.DYNAMIC_DRAW);
|
|
29005
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
29006
|
+
|
|
29007
|
+
this.vertexPosBuffer = vertexPosBuffer;
|
|
29008
|
+
this.texturePosBuffer = texturePosBuffer;
|
|
29009
|
+
};
|
|
29010
|
+
|
|
29011
|
+
/**
|
|
29012
|
+
* 创建纹理
|
|
29013
|
+
*/
|
|
29014
|
+
RenderManager.prototype.initTexture = function() {
|
|
29015
|
+
|
|
29016
|
+
var gl = this.contextGL;
|
|
29017
|
+
|
|
29018
|
+
var textureRef = gl.createTexture();
|
|
29019
|
+
gl.bindTexture(gl.TEXTURE_2D, textureRef);
|
|
29020
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
29021
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
29022
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
29023
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
29024
|
+
gl.bindTexture(gl.TEXTURE_2D, null);
|
|
29025
|
+
|
|
29026
|
+
return textureRef;
|
|
29027
|
+
};
|
|
29028
|
+
|
|
29029
|
+
/**
|
|
29030
|
+
* 初始化YUV纹理
|
|
29031
|
+
*/
|
|
29032
|
+
RenderManager.prototype.initTextures = function() {
|
|
29033
|
+
|
|
29034
|
+
var gl = this.contextGL;
|
|
29035
|
+
|
|
29036
|
+
var program = this.YUVProgram;
|
|
29037
|
+
gl.useProgram(program);
|
|
29038
|
+
|
|
29039
|
+
var yTextureRef = this.initTexture();
|
|
29040
|
+
var ySamplerRef = gl.getUniformLocation(program, 'ySampler');
|
|
29041
|
+
gl.uniform1i(ySamplerRef, 0);
|
|
29042
|
+
this.yTextureRef = yTextureRef;
|
|
29043
|
+
|
|
29044
|
+
var uTextureRef = this.initTexture();
|
|
29045
|
+
var uSamplerRef = gl.getUniformLocation(program, 'uSampler');
|
|
29046
|
+
gl.uniform1i(uSamplerRef, 1);
|
|
29047
|
+
this.uTextureRef = uTextureRef;
|
|
29048
|
+
|
|
29049
|
+
var vTextureRef = this.initTexture();
|
|
29050
|
+
var vSamplerRef = gl.getUniformLocation(program, 'vSampler');
|
|
29051
|
+
gl.uniform1i(vSamplerRef, 2);
|
|
29052
|
+
this.vTextureRef = vTextureRef;
|
|
29053
|
+
|
|
29054
|
+
gl.useProgram(null);
|
|
29055
|
+
};
|
|
29056
|
+
|
|
29057
|
+
/**
|
|
29058
|
+
* 显示帧数据
|
|
29059
|
+
* @param nWidth 宽度
|
|
29060
|
+
* @param nHeight 高度
|
|
29061
|
+
* @param nHeight 帧数据
|
|
29062
|
+
*/
|
|
29063
|
+
RenderManager.prototype.SR_DisplayFrameData = function(nWidth, nHeight, pData,dWidth,dHeight) {
|
|
29064
|
+
|
|
29065
|
+
if(nWidth <= 0 || nHeight <= 0)
|
|
29066
|
+
{
|
|
29067
|
+
return;
|
|
29068
|
+
}
|
|
29069
|
+
|
|
29070
|
+
var gl = this.contextGL;
|
|
29071
|
+
|
|
29072
|
+
if(null == pData)
|
|
29073
|
+
{
|
|
29074
|
+
gl.clearColor(0.0, 0.0, 0.0, 0.0);
|
|
29075
|
+
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
|
29076
|
+
return;
|
|
29077
|
+
}
|
|
29078
|
+
|
|
29079
|
+
var canvas = this.canvasElement;
|
|
29080
|
+
|
|
29081
|
+
this.nWindowWidth = canvas.width;
|
|
29082
|
+
this.nWindowHeight = canvas.height;
|
|
29083
|
+
|
|
29084
|
+
var nWindowWidth = this.nWindowWidth;
|
|
29085
|
+
var nWindowHeight = this.nWindowHeight;
|
|
29086
|
+
|
|
29087
|
+
gl.clearColor(0.8, 0.8, 1.0, 1.0);
|
|
29088
|
+
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
|
|
29089
|
+
|
|
29090
|
+
gl.viewport(0, 0, nWindowWidth, nWindowHeight);
|
|
29091
|
+
|
|
29092
|
+
this.updateFrameData(nWidth, nHeight, pData,dWidth,dHeight);
|
|
29093
|
+
|
|
29094
|
+
var program = this.YUVProgram;
|
|
29095
|
+
gl.useProgram(program);
|
|
29096
|
+
|
|
29097
|
+
var vertexPosBuffer = this.vertexPosBuffer;
|
|
29098
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, vertexPosBuffer);
|
|
29099
|
+
var vertexPosRef = gl.getAttribLocation(program, 'vertexPos');
|
|
29100
|
+
gl.enableVertexAttribArray(vertexPosRef);
|
|
29101
|
+
gl.vertexAttribPointer(vertexPosRef, 2, gl.FLOAT, false, 0, 0);
|
|
29102
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
29103
|
+
|
|
29104
|
+
var texturePosBuffer = this.texturePosBuffer;
|
|
29105
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, texturePosBuffer);
|
|
29106
|
+
var texturePosRef = gl.getAttribLocation(program, 'texturePos');
|
|
29107
|
+
gl.enableVertexAttribArray(texturePosRef);
|
|
29108
|
+
gl.vertexAttribPointer(texturePosRef, 2, gl.FLOAT, false, 0, 0);
|
|
29109
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
29110
|
+
|
|
29111
|
+
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
|
|
29112
|
+
|
|
29113
|
+
gl.disableVertexAttribArray(vertexPosRef);
|
|
29114
|
+
gl.disableVertexAttribArray(texturePosRef);
|
|
29115
|
+
|
|
29116
|
+
gl.useProgram(null);
|
|
29117
|
+
};
|
|
29118
|
+
|
|
29119
|
+
/**
|
|
29120
|
+
* 上传YUV数据到纹理
|
|
29121
|
+
* @param nWidth 宽度
|
|
29122
|
+
* @param nHeight 高度
|
|
29123
|
+
* @param nHeight 帧数据
|
|
29124
|
+
*/
|
|
29125
|
+
RenderManager.prototype.updateFrameData = function(width, height, data,dWidth,dHeight) {
|
|
29126
|
+
|
|
29127
|
+
var gl = this.contextGL;
|
|
29128
|
+
|
|
29129
|
+
var yTextureRef = this.yTextureRef;
|
|
29130
|
+
var uTextureRef = this.uTextureRef;
|
|
29131
|
+
var vTextureRef = this.vTextureRef;
|
|
29132
|
+
|
|
29133
|
+
var i420Data = data;
|
|
29134
|
+
// debugger;
|
|
29135
|
+
if(width == dWidth && height == dHeight)
|
|
29136
|
+
{
|
|
29137
|
+
var yDataLength = width * height;
|
|
29138
|
+
var yData = i420Data.subarray(0, yDataLength);
|
|
29139
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
29140
|
+
gl.bindTexture(gl.TEXTURE_2D, yTextureRef);
|
|
29141
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, width, height, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, yData);
|
|
29142
|
+
|
|
29143
|
+
var cbDataLength = width/2 * height/2;
|
|
29144
|
+
var cbData = i420Data.subarray(width*height, width*height + cbDataLength);
|
|
29145
|
+
gl.activeTexture(gl.TEXTURE1);
|
|
29146
|
+
gl.bindTexture(gl.TEXTURE_2D, uTextureRef);
|
|
29147
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, width/2, height/2, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, cbData);
|
|
29148
|
+
|
|
29149
|
+
var crDataLength = cbDataLength;
|
|
29150
|
+
var crData = i420Data.subarray(width*height + width*height/4, width*height + width*height/4 + crDataLength);
|
|
29151
|
+
gl.activeTexture(gl.TEXTURE2);
|
|
29152
|
+
gl.bindTexture(gl.TEXTURE_2D, vTextureRef);
|
|
29153
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, width/2, height/2, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, crData);
|
|
29154
|
+
|
|
29155
|
+
}
|
|
29156
|
+
else
|
|
29157
|
+
{
|
|
29158
|
+
// //裁剪宽
|
|
29159
|
+
var yDataLength = dWidth * dHeight;
|
|
29160
|
+
var yData=new Uint8Array(yDataLength) ;
|
|
29161
|
+
for(var i=0;i<dHeight;i++)
|
|
29162
|
+
{
|
|
29163
|
+
//var ySonData=new Uint8Array(dWidth) ;
|
|
29164
|
+
var ySonData = i420Data.subarray(i*width, i*width+dWidth);
|
|
29165
|
+
for (var j = 0; j < dWidth; j++) {
|
|
29166
|
+
yData[i*dWidth + j] = ySonData[j];
|
|
29167
|
+
}
|
|
29168
|
+
}
|
|
29169
|
+
gl.activeTexture(gl.TEXTURE0);
|
|
29170
|
+
gl.bindTexture(gl.TEXTURE_2D, yTextureRef);
|
|
29171
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, dWidth, dHeight, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, yData);
|
|
29172
|
+
yData=null;
|
|
29173
|
+
ySonData=null;
|
|
29174
|
+
|
|
29175
|
+
var cbDataLength = dWidth/2 * dHeight/2;
|
|
29176
|
+
var cbData =new Uint8Array(cbDataLength);
|
|
29177
|
+
//var cbSonData=new Uint8Array(dWidth/2) ;
|
|
29178
|
+
for(var i=0;i<dHeight/2;i++)
|
|
29179
|
+
{
|
|
29180
|
+
var cbSonData = i420Data.subarray(width*height+i*width/2, width*height+i*width/2+dWidth/2);
|
|
29181
|
+
for (var j = 0; j < dWidth/2; j++) {
|
|
29182
|
+
cbData[i*dWidth/2 + j] = cbSonData[j];
|
|
29183
|
+
}
|
|
29184
|
+
}
|
|
29185
|
+
gl.activeTexture(gl.TEXTURE1);
|
|
29186
|
+
gl.bindTexture(gl.TEXTURE_2D, uTextureRef);
|
|
29187
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, dWidth/2, dHeight/2, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, cbData);
|
|
29188
|
+
cbData=null;
|
|
29189
|
+
cbSonData=null;
|
|
29190
|
+
|
|
29191
|
+
var crDataLength = cbDataLength;
|
|
29192
|
+
var crData = new Uint8Array(crDataLength);
|
|
29193
|
+
for(var i=0;i<dHeight/2;i++)
|
|
29194
|
+
{
|
|
29195
|
+
var crSonData = i420Data.subarray(width*height*5/4+i*width/2, width*height*5/4+i*width/2+dWidth/2);
|
|
29196
|
+
for (var j = 0; j < dWidth/2; j++) {
|
|
29197
|
+
crData[i*dWidth/2 + j] = crSonData[j];
|
|
29198
|
+
}
|
|
29199
|
+
}
|
|
29200
|
+
gl.activeTexture(gl.TEXTURE2);
|
|
29201
|
+
gl.bindTexture(gl.TEXTURE_2D, vTextureRef);
|
|
29202
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.LUMINANCE, dWidth/2, dHeight/2, 0, gl.LUMINANCE, gl.UNSIGNED_BYTE, crData);
|
|
29203
|
+
crData=null;
|
|
29204
|
+
crSonData=null;
|
|
29205
|
+
}
|
|
29206
|
+
|
|
29207
|
+
};
|
|
29208
|
+
|
|
29209
|
+
/**
|
|
29210
|
+
* 设置显示区域
|
|
29211
|
+
* @param stDisplayRect 显示区域
|
|
29212
|
+
*/
|
|
29213
|
+
RenderManager.prototype.SR_SetDisplayRect = function(stDisplayRect) {
|
|
29214
|
+
|
|
29215
|
+
var gl = this.contextGL;
|
|
29216
|
+
|
|
29217
|
+
var nWindowWidth = this.nWindowWidth;
|
|
29218
|
+
var nWindowHeight = this.nWindowHeight;
|
|
29219
|
+
|
|
29220
|
+
var texturePosValues = null;
|
|
29221
|
+
|
|
29222
|
+
if(stDisplayRect && nWindowWidth > 0 && nWindowHeight > 0) {
|
|
29223
|
+
var fLeft = stDisplayRect.left / nWindowWidth;
|
|
29224
|
+
var fTop = stDisplayRect.top / nWindowHeight;
|
|
29225
|
+
var fRight = stDisplayRect.right / nWindowWidth;
|
|
29226
|
+
var fBottom = stDisplayRect.bottom / nWindowHeight;
|
|
29227
|
+
|
|
29228
|
+
texturePosValues = new Float32Array([fRight, fTop, fLeft, fTop, fRight, fBottom, fLeft, fBottom]);
|
|
29229
|
+
}
|
|
29230
|
+
else {
|
|
29231
|
+
texturePosValues = new Float32Array([1, 0, 0, 0, 1, 1, 0, 1]);
|
|
29232
|
+
}
|
|
29233
|
+
|
|
29234
|
+
var texturePosBuffer = this.texturePosBuffer;
|
|
29235
|
+
|
|
29236
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, texturePosBuffer);
|
|
29237
|
+
gl.bufferSubData(gl.ARRAY_BUFFER, 0, texturePosValues);
|
|
29238
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
29239
|
+
};
|
|
29240
|
+
|
|
29241
|
+
/**
|
|
29242
|
+
* 释放显示资源
|
|
29243
|
+
*/
|
|
29244
|
+
RenderManager.prototype.SR_Destroy = function() {
|
|
29245
|
+
|
|
29246
|
+
var gl = this.contextGL;
|
|
29247
|
+
|
|
29248
|
+
var YUVProgram = this.YUVProgram;
|
|
29249
|
+
gl.deleteProgram(YUVProgram);
|
|
29250
|
+
|
|
29251
|
+
var vertexPosBuffer = this.vertexPosBuffer;
|
|
29252
|
+
var texturePosBuffer = this.texturePosBuffer;
|
|
29253
|
+
|
|
29254
|
+
gl.deleteBuffer(vertexPosBuffer);
|
|
29255
|
+
gl.deleteBuffer(texturePosBuffer);
|
|
29256
|
+
|
|
29257
|
+
var yTextureRef = this.yTextureRef;
|
|
29258
|
+
var uTextureRef = this.uTextureRef;
|
|
29259
|
+
var vTextureRef = this.vTextureRef;
|
|
29260
|
+
gl.deleteTexture(yTextureRef);
|
|
29261
|
+
gl.deleteTexture(uTextureRef);
|
|
29262
|
+
gl.deleteTexture(vTextureRef);
|
|
29263
|
+
};
|
|
29264
|
+
|
|
29265
|
+
return RenderManager;
|
|
29266
|
+
|
|
29267
|
+
}));
|
|
29268
|
+
|
|
28600
29269
|
/* eslint-disable valid-jsdoc */
|
|
29270
|
+
// import './jsPlugin-4.0.2.min.js';
|
|
28601
29271
|
|
|
28602
29272
|
// iframe模板 - 兼容旧版本
|
|
28603
29273
|
const matchTemplate = (templateName, params) => {
|
|
28604
|
-
const IFRAMETEMPLATE = ['simple', 'standard', 'security', '
|
|
28605
|
-
const LOCALTEMPLATE = ['pcLive', 'pcRec', 'mobileLive', 'mobileRec', 'noData'];
|
|
29274
|
+
const IFRAMETEMPLATE = ['simple', 'standard', 'security', 'voice', 'theme'];
|
|
29275
|
+
const LOCALTEMPLATE = ['pcLive', 'pcRec', 'mobileLive', 'mobileRec', 'noData', ''];
|
|
28606
29276
|
if (typeof templateName === 'undefined') {
|
|
29277
|
+
if (params.themeData) {
|
|
29278
|
+
return {
|
|
29279
|
+
templateType: 'themeData',
|
|
29280
|
+
templateId: 'themeData'
|
|
29281
|
+
}
|
|
29282
|
+
}
|
|
28607
29283
|
return {
|
|
28608
29284
|
templateType: 'local',
|
|
28609
29285
|
templateId: ''
|
|
@@ -28650,6 +29326,9 @@ class EZUIKitPlayer {
|
|
|
28650
29326
|
}
|
|
28651
29327
|
};
|
|
28652
29328
|
if (matchTemplate(this.params.template, params).templateType !== 'iframe') {
|
|
29329
|
+
this.Monitor = new Monitor({
|
|
29330
|
+
env: !(typeof params.disableMonitor !== 'undefined' && params.disableMonitor) ? 'online' : 'test12',
|
|
29331
|
+
});
|
|
28653
29332
|
this.id = params.id;
|
|
28654
29333
|
this.width = params.width;
|
|
28655
29334
|
this.height = params.height;
|
|
@@ -28657,44 +29336,81 @@ class EZUIKitPlayer {
|
|
|
28657
29336
|
this.accessToken = params.accessToken;
|
|
28658
29337
|
this.themeId = matchTemplate(params.template, params).templateId;
|
|
28659
29338
|
this.id = params.id;
|
|
28660
|
-
this.audio =
|
|
29339
|
+
this.audio = true;
|
|
28661
29340
|
this.poster = params.poster;
|
|
28662
29341
|
this.speed = 1;
|
|
29342
|
+
this.env = {
|
|
29343
|
+
domain: "https://open.ys7.com"
|
|
29344
|
+
};
|
|
28663
29345
|
this.staticPath = "https://open.ys7.com/assets/ezuikit_v4.0";
|
|
28664
29346
|
if (typeof params.staticPath === 'string') {
|
|
28665
29347
|
this.staticPath = params.staticPath;
|
|
28666
29348
|
}
|
|
28667
|
-
|
|
28668
|
-
|
|
28669
|
-
|
|
28670
|
-
|
|
28671
|
-
|
|
28672
|
-
|
|
28673
|
-
|
|
28674
|
-
|
|
28675
|
-
|
|
28676
|
-
|
|
28677
|
-
|
|
28678
|
-
|
|
28679
|
-
|
|
28680
|
-
|
|
28681
|
-
|
|
28682
|
-
|
|
28683
|
-
|
|
28684
|
-
|
|
28685
|
-
|
|
28686
|
-
|
|
28687
|
-
|
|
28688
|
-
|
|
28689
|
-
|
|
28690
|
-
|
|
28691
|
-
|
|
28692
|
-
|
|
28693
|
-
|
|
28694
|
-
|
|
29349
|
+
if (typeof params.audio !== 'undefined') {
|
|
29350
|
+
this.audio = params.audio;
|
|
29351
|
+
}
|
|
29352
|
+
addJs(`${this.staticPath}/js/jsPlugin-4.0.2.min.js`, () => {
|
|
29353
|
+
if (autoplay) {
|
|
29354
|
+
this.initTime = new Date().getTime();
|
|
29355
|
+
this.Monitor.dclog({
|
|
29356
|
+
url: this.url,
|
|
29357
|
+
action: 0,
|
|
29358
|
+
text: 'startInit',
|
|
29359
|
+
});
|
|
29360
|
+
var initEZUIKitPlayerPromise = this.initEZUIKitPlayer(params);
|
|
29361
|
+
var getRealUrlPromise = this._getRealUrlPromise(params.accessToken, params.url);
|
|
29362
|
+
Promise.all([initEZUIKitPlayerPromise, getRealUrlPromise]).then(values => {
|
|
29363
|
+
if (values[1]) {
|
|
29364
|
+
this._pluginPlay(values[1],
|
|
29365
|
+
() => {
|
|
29366
|
+
console.log("自动播放成功");
|
|
29367
|
+
this.Monitor.dclog({
|
|
29368
|
+
url: this.url,
|
|
29369
|
+
action: 202,
|
|
29370
|
+
d: new Date().getTime() - this.initTime,
|
|
29371
|
+
text: 'autoPlaySuccess'
|
|
29372
|
+
});
|
|
29373
|
+
},
|
|
29374
|
+
() => {
|
|
29375
|
+
console.log("自动播放失败");
|
|
29376
|
+
this.Monitor.dclog({
|
|
29377
|
+
url: this.url,
|
|
29378
|
+
action: 402,
|
|
29379
|
+
d: new Date().getTime() - this.initTime,
|
|
29380
|
+
text: 'autoPlayError'
|
|
29381
|
+
});
|
|
29382
|
+
},
|
|
29383
|
+
);
|
|
29384
|
+
}
|
|
29385
|
+
window.EZUIKit[params.id].state.EZUIKitPlayer.init = true;
|
|
29386
|
+
if (document.getElementById(`${params.id}canvas_draw0`)) {
|
|
29387
|
+
document.getElementById(`${params.id}canvas_draw0`).style.border = "none";
|
|
28695
29388
|
}
|
|
28696
29389
|
});
|
|
28697
|
-
}
|
|
29390
|
+
} else {
|
|
29391
|
+
this.initTime = new Date().getTime();
|
|
29392
|
+
this.Monitor.dclog({
|
|
29393
|
+
url: this.url,
|
|
29394
|
+
action: 0,
|
|
29395
|
+
text: 'startInit',
|
|
29396
|
+
});
|
|
29397
|
+
var initEZUIKitPlayerPromise = this.initEZUIKitPlayer(params);
|
|
29398
|
+
initEZUIKitPlayerPromise.then((data) => {
|
|
29399
|
+
console.log("初始化成功", data);
|
|
29400
|
+
window.EZUIKit[params.id].state.EZUIKitPlayer.init = true;
|
|
29401
|
+
if (document.getElementById(`${params.id}canvas_draw0`)) {
|
|
29402
|
+
document.getElementById(`${params.id}canvas_draw0`).style.border = "none";
|
|
29403
|
+
}
|
|
29404
|
+
this.Monitor.dclog({
|
|
29405
|
+
url: this.url,
|
|
29406
|
+
action: 201,
|
|
29407
|
+
d: new Date().getTime() - this.initTime,
|
|
29408
|
+
text: 'initSuccess',
|
|
29409
|
+
});
|
|
29410
|
+
});
|
|
29411
|
+
}
|
|
29412
|
+
},()=>{
|
|
29413
|
+
return !!window.JSPlugin;
|
|
28698
29414
|
});
|
|
28699
29415
|
if ((params.plugin && params.plugin.indexOf("talk") !== -1)) {
|
|
28700
29416
|
this.Talk = new Talk(this);
|
|
@@ -28763,8 +29479,10 @@ class EZUIKitPlayer {
|
|
|
28763
29479
|
},
|
|
28764
29480
|
windowFullCcreenChange: function (bFull) {
|
|
28765
29481
|
},
|
|
28766
|
-
firstFrameDisplay:
|
|
29482
|
+
firstFrameDisplay: (iWndIndex, iWidth, iHeight) => {
|
|
29483
|
+
console.log(iWidth, iHeight);
|
|
28767
29484
|
jSPlugin.JS_SetCanFullScreen(false);
|
|
29485
|
+
this.pluginStatus.loadingClear();
|
|
28768
29486
|
},
|
|
28769
29487
|
performanceLack: function () {
|
|
28770
29488
|
},
|
|
@@ -28801,8 +29519,8 @@ class EZUIKitPlayer {
|
|
|
28801
29519
|
}
|
|
28802
29520
|
_getRealUrlPromise(accessToken, url) {
|
|
28803
29521
|
var apiDomain = this.env.domain;
|
|
28804
|
-
if (this.
|
|
28805
|
-
apiDomain = this.
|
|
29522
|
+
if (this.env) {
|
|
29523
|
+
apiDomain = this.env.domain;
|
|
28806
29524
|
}
|
|
28807
29525
|
var getRealUrlPromise = (resolve, reject) => {
|
|
28808
29526
|
var realUrl = '';
|
|
@@ -29138,6 +29856,12 @@ class EZUIKitPlayer {
|
|
|
29138
29856
|
});
|
|
29139
29857
|
}
|
|
29140
29858
|
successCallback();
|
|
29859
|
+
this.Monitor.dclog({
|
|
29860
|
+
url: this.url,
|
|
29861
|
+
action: 211,
|
|
29862
|
+
d: new Date().getTime() - this.playStartTime,
|
|
29863
|
+
text: 'startPlaySuccess'
|
|
29864
|
+
});
|
|
29141
29865
|
}, (err) => {
|
|
29142
29866
|
var errorInfo = this.errorHander.matchErrorInfo(err.oError.errorCode);
|
|
29143
29867
|
var msg = errorInfo ? errorInfo.description : '播放失败,请检查设备及客户端网络';
|
|
@@ -29153,18 +29877,31 @@ class EZUIKitPlayer {
|
|
|
29153
29877
|
type: "handleError"
|
|
29154
29878
|
});
|
|
29155
29879
|
}
|
|
29156
|
-
|
|
29880
|
+
errorCallback();
|
|
29881
|
+
this.Monitor.dclog({
|
|
29882
|
+
url: this.url,
|
|
29883
|
+
action: 411,
|
|
29884
|
+
d: new Date().getTime() - this.playStartTime,
|
|
29885
|
+
text: 'startPlayError'
|
|
29886
|
+
});
|
|
29157
29887
|
});
|
|
29158
29888
|
}
|
|
29159
29889
|
play(options) {
|
|
29160
|
-
|
|
29161
|
-
|
|
29890
|
+
this.playStartTime = new Date().getTime();
|
|
29891
|
+
this.Monitor.dclog({
|
|
29892
|
+
url: this.url,
|
|
29893
|
+
action: 1,
|
|
29894
|
+
d: new Date().getTime() - this.initTime,
|
|
29895
|
+
text: 'startPlay'
|
|
29896
|
+
});
|
|
29897
|
+
if (options) {
|
|
29898
|
+
if (typeof options.url === 'string') {
|
|
29162
29899
|
this.url = options.url;
|
|
29163
29900
|
}
|
|
29164
|
-
if(typeof options.accessToken === 'string') {
|
|
29165
|
-
this.accessToken =
|
|
29901
|
+
if (typeof options.accessToken === 'string') {
|
|
29902
|
+
this.accessToken = options.accessToken;
|
|
29166
29903
|
}
|
|
29167
|
-
if(this.Theme && (typeof options.url === 'string' || typeof options.accessToken === 'string')) {
|
|
29904
|
+
if (this.Theme && (typeof options.url === 'string' || typeof options.accessToken === 'string')) {
|
|
29168
29905
|
this.Theme.getDeviceInfo();
|
|
29169
29906
|
}
|
|
29170
29907
|
}
|
|
@@ -29172,63 +29909,6 @@ class EZUIKitPlayer {
|
|
|
29172
29909
|
this._getRealUrlPromise(this.accessToken, this.url)
|
|
29173
29910
|
.then((data) => {
|
|
29174
29911
|
this._pluginPlay(data, () => resolve(true), () => reject(false));
|
|
29175
|
-
// console.log("get real url result ===", data);
|
|
29176
|
-
// function getPlayParams(url) {
|
|
29177
|
-
// var websocketConnectUrl = url.split('?')[0].replace('/live', '').replace('/playback', '');
|
|
29178
|
-
// var websocketStreamingParam = (url.indexOf('/live') === -1 ? (url.indexOf('cloudplayback') !== -1 ? '/cloudplayback?' : '/playback?') : '/live?') + url.split('?')[1];
|
|
29179
|
-
// if (websocketStreamingParam.indexOf('/playback') !== -1) {
|
|
29180
|
-
// websocketStreamingParam = websocketStreamingParam.replace("stream=2", 'stream=1');
|
|
29181
|
-
// }
|
|
29182
|
-
// // 本地回放仅支持主码流
|
|
29183
|
-
// return {
|
|
29184
|
-
// websocketConnectUrl: websocketConnectUrl,
|
|
29185
|
-
// websocketStreamingParam: websocketStreamingParam
|
|
29186
|
-
// };
|
|
29187
|
-
// }
|
|
29188
|
-
// var wsUrl = getPlayParams(data).websocketConnectUrl;
|
|
29189
|
-
// if(this.env && this.env.wsUrl) {
|
|
29190
|
-
// wsUrl = this.env.wsUrl;
|
|
29191
|
-
// }
|
|
29192
|
-
// var wsParams = {
|
|
29193
|
-
// playURL: getPlayParams(data).websocketStreamingParam
|
|
29194
|
-
// };
|
|
29195
|
-
|
|
29196
|
-
// this.jSPlugin.JS_Play(wsUrl, wsParams, 0).then(() => {
|
|
29197
|
-
// console.log("播放成功");
|
|
29198
|
-
// this.pluginStatus.loadingClear();
|
|
29199
|
-
// if (this.Theme) {
|
|
29200
|
-
// this.Theme.setDecoderState({ play: true });
|
|
29201
|
-
// }
|
|
29202
|
-
// if (this.audio) {
|
|
29203
|
-
// setTimeout(() => {
|
|
29204
|
-
// this.openSound();
|
|
29205
|
-
// }, 500);
|
|
29206
|
-
// }
|
|
29207
|
-
// if (typeof this.params.handleSuccess === 'function') {
|
|
29208
|
-
// this.params.handleSuccess({
|
|
29209
|
-
// retcode: 0,
|
|
29210
|
-
// id: this.params.id,
|
|
29211
|
-
// type: "handleSuccess"
|
|
29212
|
-
// });
|
|
29213
|
-
// }
|
|
29214
|
-
// resolve(true);
|
|
29215
|
-
// }, (err) => {
|
|
29216
|
-
// var errorInfo = this.errorHander.matchErrorInfo(err.oError.errorCode);
|
|
29217
|
-
// var msg = errorInfo ? errorInfo.description : '播放失败,请检查设备及客户端网络';
|
|
29218
|
-
// this.pluginStatus.loadingSetText({
|
|
29219
|
-
// text: msg,
|
|
29220
|
-
// color: 'red'
|
|
29221
|
-
// });
|
|
29222
|
-
// if (typeof this.params.handleError === 'function') {
|
|
29223
|
-
// this.params.handleError({
|
|
29224
|
-
// retcode: err.oError.errorCode,
|
|
29225
|
-
// msg: msg,
|
|
29226
|
-
// id: this.params.id,
|
|
29227
|
-
// type: "handleError"
|
|
29228
|
-
// });
|
|
29229
|
-
// }
|
|
29230
|
-
// reject(false);
|
|
29231
|
-
// });
|
|
29232
29912
|
})
|
|
29233
29913
|
.catch((err) => {
|
|
29234
29914
|
var msg = err.msg ? err.msg : '播放失败,请检查设备及客户端网络';
|
|
@@ -29354,7 +30034,7 @@ class EZUIKitPlayer {
|
|
|
29354
30034
|
});
|
|
29355
30035
|
// 兼容旧版本callback
|
|
29356
30036
|
if (typeof this.params.getOSDTimeCallBack === 'function') {
|
|
29357
|
-
this.params.getOSDTimeCallBack({ id: this.id, type: 'getOSDTime', code: 0, data: data});
|
|
30037
|
+
this.params.getOSDTimeCallBack({ id: this.id, type: 'getOSDTime', code: 0, data: data });
|
|
29358
30038
|
}
|
|
29359
30039
|
})
|
|
29360
30040
|
.catch(err => {
|
|
@@ -29365,7 +30045,7 @@ class EZUIKitPlayer {
|
|
|
29365
30045
|
});
|
|
29366
30046
|
// 兼容旧版本callback
|
|
29367
30047
|
if (typeof this.params.getOSDTimeCallBack === 'function') {
|
|
29368
|
-
this.params.getOSDTimeCallBack({ id: this.id, type: 'getOSDTime', code: -1,data: -1 });
|
|
30048
|
+
this.params.getOSDTimeCallBack({ id: this.id, type: 'getOSDTime', code: -1, data: -1 });
|
|
29369
30049
|
}
|
|
29370
30050
|
});
|
|
29371
30051
|
});
|
|
@@ -29545,6 +30225,53 @@ class EZUIKitPlayer {
|
|
|
29545
30225
|
});
|
|
29546
30226
|
}
|
|
29547
30227
|
seek(startTime, endTime) {
|
|
30228
|
+
var url = this.url;
|
|
30229
|
+
var currentDay = (getQueryString(url, 'begin') || new Date().Format('yyyyMMdd')).substr(0, 8);
|
|
30230
|
+
endTime = formatRecTime(currentDay, '235959');
|
|
30231
|
+
if (startTime.length === 6) {
|
|
30232
|
+
startTime = formatRecTime(currentDay, startTime);
|
|
30233
|
+
} else if (startTime.length === 16) {
|
|
30234
|
+
if (startTime.substr(0, 8) !== currentDay) {
|
|
30235
|
+
this.params.handleError({
|
|
30236
|
+
msg: "seek时间不能跨日期",
|
|
30237
|
+
retcode: -1,
|
|
30238
|
+
id: this.id,
|
|
30239
|
+
type: "handleError"
|
|
30240
|
+
});
|
|
30241
|
+
return false;
|
|
30242
|
+
}
|
|
30243
|
+
} else {
|
|
30244
|
+
this.params.handleError({
|
|
30245
|
+
msg: "seek时间格式错误",
|
|
30246
|
+
retcode: -1,
|
|
30247
|
+
id: this.id,
|
|
30248
|
+
type: "handleError"
|
|
30249
|
+
});
|
|
30250
|
+
return false;
|
|
30251
|
+
}
|
|
30252
|
+
// 格式化回放时间
|
|
30253
|
+
function formatRecTime(time, defaultTime) {
|
|
30254
|
+
// 用户格式 无需更改 => 20182626T000000Z
|
|
30255
|
+
// return time
|
|
30256
|
+
// 用户格式需要更改
|
|
30257
|
+
//用户时间长度为 14 20181226000000 =》 20181226000000
|
|
30258
|
+
// 用户长度为12 201812260000 =》 201812260000 + defaultTime后面2位
|
|
30259
|
+
// 用户长度为10 2018122600 =》 201812260000 + defaultTime后面4位
|
|
30260
|
+
// 用户长度为8 20181226 =》 201812260000 + defaultTime后面6位
|
|
30261
|
+
// 结果 20181226000000 14位
|
|
30262
|
+
// 插入 TZ
|
|
30263
|
+
var reg = /^[0-9]{8}T[0-9]{6}Z$/;
|
|
30264
|
+
if (reg.test(time)) { // 用户格式 无需更改 => 20182626T000000Z
|
|
30265
|
+
return time;
|
|
30266
|
+
} else if (/[0-9]{8,14}/.test(time)) {
|
|
30267
|
+
var start = 6 - (14 - time.length);
|
|
30268
|
+
var end = defaultTime.length;
|
|
30269
|
+
var standardTime = time + defaultTime.substring(start, end);
|
|
30270
|
+
return standardTime.slice(0, 8) + 'T' + standardTime.slice(8) + 'Z';
|
|
30271
|
+
} else {
|
|
30272
|
+
throw new Error('回放时间格式有误,请确认');
|
|
30273
|
+
}
|
|
30274
|
+
}
|
|
29548
30275
|
var seekRT = this.jSPlugin.JS_Seek(0, startTime, endTime);
|
|
29549
30276
|
console.log("seekRT", seekRT);
|
|
29550
30277
|
if (isPromise(seekRT)) {
|
|
@@ -29592,6 +30319,19 @@ class EZUIKitPlayer {
|
|
|
29592
30319
|
stopTalk() {
|
|
29593
30320
|
this.Talk.startTalk();
|
|
29594
30321
|
}
|
|
30322
|
+
destroy() {
|
|
30323
|
+
var destroyRT = this.jSPlugin.JS_DestroyWorker(0);
|
|
30324
|
+
if (this.Theme) {
|
|
30325
|
+
this.Theme = null;
|
|
30326
|
+
window.EZUIKit[this.params.id].state.EZUIKitPlayer.themeInit = false;
|
|
30327
|
+
}
|
|
30328
|
+
if (isPromise(destroyRT)) {
|
|
30329
|
+
return destroyRT;
|
|
30330
|
+
}
|
|
30331
|
+
return new Promise(function (resolve) {
|
|
30332
|
+
resolve(destroyRT);
|
|
30333
|
+
});
|
|
30334
|
+
}
|
|
29595
30335
|
}
|
|
29596
30336
|
|
|
29597
30337
|
(function (global, factory) {
|