ucservice 1.5.0 → 1.5.3

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.
@@ -12113,6 +12113,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
12113
12113
  }
12114
12114
 
12115
12115
  return e.returnValue;
12116
+ },
12117
+
12118
+ /**
12119
+ * 清空事件
12120
+ */
12121
+ removeAllListeners: function () {
12122
+ this._listeners = {};
12116
12123
  }
12117
12124
  };
12118
12125
  let videoListener = new Listener();
@@ -12753,21 +12760,21 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
12753
12760
  * 添加事件
12754
12761
  */
12755
12762
  addListener: function (type, handler, key) {
12756
- videoListener.addListener(type, handler, key);
12763
+ this.videoListener.addListener(type, handler, key);
12757
12764
  },
12758
12765
 
12759
12766
  /**
12760
12767
  * 删除事件
12761
12768
  */
12762
12769
  removeListener: function (type, handler) {
12763
- videoListener.removeListener(type, handler);
12770
+ this.videoListener.removeListener(type, handler);
12764
12771
  },
12765
12772
 
12766
12773
  /**
12767
12774
  * 派发事件
12768
12775
  */
12769
12776
  dispatch: function (e, options) {
12770
- videoListener.dispatch(e, options);
12777
+ this.videoListener.dispatch(e, options);
12771
12778
  },
12772
12779
 
12773
12780
  /**
@@ -13163,11 +13170,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13163
13170
  function VideoWebRtc($dom, opts) {
13164
13171
  let _self = this;
13165
13172
 
13173
+ _self.videoListener = new Listener();
13174
+
13166
13175
  if (!opts) {
13167
13176
  console.error('VideoWebRtc的参数opts不能为空');
13168
13177
  return;
13169
13178
  }
13170
13179
 
13180
+ _self.configOpt = opts && opts.configOpt || 3;
13171
13181
  hasMediaDevices(); //检测声卡设备为异步方法,耗时在几十毫秒左右,因此需要做延迟
13172
13182
  //默认检查次数为40 间隔为20ms
13173
13183
 
@@ -13177,11 +13187,59 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13177
13187
  clearInterval(index);
13178
13188
 
13179
13189
  _self._init($dom, opts);
13190
+
13191
+ let resizeObserver = new ResizeObserver(function (entries) {
13192
+ // console.log(entries)
13193
+ entries.forEach((item, index) => {
13194
+ let target = item.target;
13195
+ let videoLi = document.getElementById(me.selector).querySelectorAll('li');
13196
+
13197
+ _self.VIDEO_DATA.forEach((item, index) => {
13198
+ let tel = item.video;
13199
+
13200
+ if (!tel && item.id) {
13201
+ videoLi[index].querySelector('video').style = '';
13202
+ videoLi[index].querySelector('.rotate-btn').setAttribute('rotate-index', 0);
13203
+ } else {
13204
+ let rotateIndex = $(videoLi[index]).find('button[name=rotateVideo]').attr('rotate-index');
13205
+ setTimeout(() => {
13206
+ _self.videoRotateSize(videoLi[index], rotateIndex);
13207
+ }, 200);
13208
+ }
13209
+ });
13210
+ });
13211
+ }); // 监听dom
13212
+
13213
+ resizeObserver.observe(document.querySelector(_self.selector));
13180
13214
  } else {
13181
13215
  if (window.checkAudioDevicesStatus) {
13182
13216
  clearInterval(index);
13183
13217
 
13184
13218
  _self._init($dom, opts);
13219
+
13220
+ let resizeObserver = new ResizeObserver(function (entries) {
13221
+ // console.log(entries)
13222
+ entries.forEach((item, index) => {
13223
+ let target = item.target;
13224
+ let videoLi = document.getElementById(me.selector).querySelectorAll('li');
13225
+
13226
+ _self.VIDEO_DATA.forEach((item, index) => {
13227
+ let tel = item.video;
13228
+
13229
+ if (!tel && item.id) {
13230
+ videoLi[index].querySelector('video').style = '';
13231
+ videoLi[index].querySelector('.rotate-btn').setAttribute('rotate-index', 0);
13232
+ } else {
13233
+ let rotateIndex = $(videoLi[index]).find('button[name=rotateVideo]').attr('rotate-index');
13234
+ setTimeout(() => {
13235
+ _self.videoRotateSize(videoLi[index], rotateIndex);
13236
+ }, 200);
13237
+ }
13238
+ });
13239
+ });
13240
+ }); // 监听dom
13241
+
13242
+ resizeObserver.observe(document.querySelector(_self.selector));
13185
13243
  }
13186
13244
  }
13187
13245
 
@@ -13208,6 +13266,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13208
13266
  // console.info('该视频正在播放');
13209
13267
  // return false;
13210
13268
  // }
13269
+ // 启用播放队列时,当前位置正在关闭上一个视频,则加入播放队列
13270
+
13271
+ if (me.waitPlayQueueSwitch && me.VIDEO_DATA[index].isClosing) {
13272
+ me._addWaitingVideo(index, video, id, opts);
13273
+
13274
+ return;
13275
+ }
13211
13276
 
13212
13277
  console.log("play >>> " + "video=" + video + "; id=" + id + "; index=" + index);
13213
13278
  me.dispatch('beforeplay', {
@@ -13306,7 +13371,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13306
13371
  */
13307
13372
  playInChoice: function (video, id, opts) {
13308
13373
  let me = this;
13309
- let selView = $('[video-flag="' + me._opts.windowsBeginIndex + '"]>li.sel');
13374
+ let selView = $(me.selector + ' li.sel');
13310
13375
 
13311
13376
  if (selView.length) {
13312
13377
  if (me.VIDEO_DATA[selView.index()].playing) {
@@ -13363,6 +13428,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13363
13428
  this.VIDEO_DATA[index].close();
13364
13429
 
13365
13430
  if (!isSave) {
13431
+ this.VIDEO_DATA[index].closeType = 'close';
13366
13432
  this.dispatch('afterclose', this.VIDEO_DATA[index]);
13367
13433
  }
13368
13434
  },
@@ -13389,6 +13455,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13389
13455
  me.close(videoData[i].index);
13390
13456
 
13391
13457
  if (!isSave) {
13458
+ videoData[i].closeType = 'close';
13392
13459
  me.dispatch('afterclose', videoData[i]);
13393
13460
  }
13394
13461
  }
@@ -13399,13 +13466,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13399
13466
  * 关闭所有视频
13400
13467
  */
13401
13468
  closeAll: function (isSave) {
13402
- let me = this;
13469
+ let me = this; // 清除所有等待播放队列
13470
+
13471
+ me._removeAllWaitingVideo();
13472
+
13403
13473
  let openVideos = [];
13404
13474
 
13405
13475
  for (let i = me._opts.windowsBeginIndex; i < me._opts.windowsBeginIndex + me._opts.windowsNum; i++) {
13406
- if (me.VIDEO_DATA[i].playing) {
13407
- me.close(i, isSave);
13408
- }
13476
+ // if(me.VIDEO_DATA[i].playing){
13477
+ // me.close(i, isSave)
13478
+ // }
13479
+ me.close(i, isSave);
13409
13480
  } // if(!openVideos.length) return;
13410
13481
  //
13411
13482
  // //适当延时进行关闭
@@ -13445,9 +13516,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13445
13516
  me.setChoiceWindow(me._getMinIndexFreeWindow());
13446
13517
  }
13447
13518
 
13448
- $('[video-flag="' + me._opts.windowsBeginIndex + '"]').removeClass("mode-" + me._opts.windows).addClass("mode-" + num);
13519
+ $(me.selector + ' .video-main').removeClass("mode-" + me._opts.windows).addClass("mode-" + num);
13449
13520
 
13450
- let _li = $('[video-flag="' + me._opts.windowsBeginIndex + '"]>li').hide();
13521
+ let _li = $(me.selector + ' li').hide();
13451
13522
 
13452
13523
  me._opts.windows = num;
13453
13524
 
@@ -13461,7 +13532,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13461
13532
  flag: me._opts.flag
13462
13533
  }); //设置旋转了的视频样式
13463
13534
 
13464
- let videoLi = document.getElementById('videoRef').querySelectorAll('li');
13535
+ let videoLi = document.getElementById(me.selector).querySelectorAll('li');
13465
13536
  me.VIDEO_DATA.forEach((item, index) => {
13466
13537
  let tel = item.video;
13467
13538
 
@@ -13472,13 +13543,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13472
13543
  }); //设置旋转视频的样式
13473
13544
 
13474
13545
  for (let k = 0; k < _li.length; k++) {
13475
- let rotateIndex = _li.eq(k).find('button[name=rotateVideo]').attr('rotate-index');
13546
+ let rotateIndex = _li.eq(k).find('button[name=rotateVideo]').attr('rotate-index'); // if(rotateIndex != 0 && rotateIndex != 2){
13476
13547
 
13477
- if (rotateIndex != 0 && rotateIndex != 2) {
13478
- setTimeout(() => {
13479
- me.videoRotateSize(_li.eq(k)[0], rotateIndex);
13480
- }, 200);
13481
- }
13548
+
13549
+ setTimeout(() => {
13550
+ me.videoRotateSize(_li.eq(k)[0], rotateIndex);
13551
+ }, 200); // }
13482
13552
  }
13483
13553
  },
13484
13554
 
@@ -13507,7 +13577,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13507
13577
  me.saveList();
13508
13578
  this._polltimer = new PollTimer(function (firstRun) {
13509
13579
  me.closeAll();
13510
- wait(500).then(function () {
13580
+
13581
+ if (firstRun) {
13511
13582
  for (let i = 0; i < windowNum; i++) {
13512
13583
  if (nowNum == maxNum) {
13513
13584
  nowNum = 0;
@@ -13521,10 +13592,23 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13521
13592
  nowNum++;
13522
13593
  }
13523
13594
 
13524
- if (firstRun) {
13525
- me.dispatch('startpoll', array);
13526
- }
13527
- });
13595
+ me.dispatch('startpoll', array);
13596
+ } else {
13597
+ wait(1500).then(function () {
13598
+ for (let i = 0; i < windowNum; i++) {
13599
+ if (nowNum == maxNum) {
13600
+ nowNum = 0;
13601
+
13602
+ if (maxNum < windowNum) {
13603
+ break;
13604
+ }
13605
+ }
13606
+
13607
+ me.playByOrder(array[nowNum].video, array[nowNum].id, array[nowNum].opts);
13608
+ nowNum++;
13609
+ }
13610
+ });
13611
+ }
13528
13612
  }, time);
13529
13613
  },
13530
13614
 
@@ -13647,10 +13731,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13647
13731
  */
13648
13732
  getInChoiceVideo: function () {
13649
13733
  let me = this;
13650
- let selView = $('[video-flag="' + me._opts.windowsBeginIndex + '"]>li.sel');
13734
+ let selView = $(me.selector + ' li.sel');
13651
13735
 
13652
- if (selView.length && me.VIDEO_DATA[selView.index()].video) {
13653
- return me.VIDEO_DATA[selView.index()];
13736
+ if (selView.length && me.VIDEO_DATA[selView.attr("index")].video) {
13737
+ return me.VIDEO_DATA[selView.attr("index")];
13654
13738
  }
13655
13739
 
13656
13740
  return undefined;
@@ -13686,10 +13770,23 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13686
13770
 
13687
13771
  let canvasObj = document.getElementById('myCanvas');
13688
13772
  let videoObj = dataObj.tagBox.get(0);
13689
- canvasObj.width = dataObj.tagBox.parent().width();
13690
- canvasObj.height = dataObj.tagBox.parent().height();
13773
+
13774
+ if (videoObj == undefined) {
13775
+ return;
13776
+ } // 取流中 取视频框尺寸
13777
+ // 播放中 取视频画面尺寸
13778
+
13779
+
13780
+ if (dataObj.tagBox.parent().find(".stream-loading").length != 0) {
13781
+ canvasObj.width = dataObj.tagBox.width();
13782
+ canvasObj.height = dataObj.tagBox.height();
13783
+ } else {
13784
+ canvasObj.width = videoObj.videoWidth;
13785
+ canvasObj.height = videoObj.videoHeight;
13786
+ }
13787
+
13691
13788
  let ctx = canvasObj.getContext("2d");
13692
- ctx.drawImage(videoObj, 0, 0, dataObj.tagBox.parent().width(), dataObj.tagBox.parent().height());
13789
+ ctx.drawImage(videoObj, 0, 0, videoObj.videoWidth, videoObj.videoHeight);
13693
13790
  let dataUrl = canvasObj.toDataURL('image/jpeg');
13694
13791
  callback ? callback(dataUrl) : null;
13695
13792
  },
@@ -13736,8 +13833,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13736
13833
 
13737
13834
  if (index < 0) {
13738
13835
  console.error('窗口编号获取失败!');
13739
- }
13836
+ } //保存对讲号码
13837
+
13740
13838
 
13839
+ window.pocNo = pocNo;
13741
13840
  return me.VIDEO_DATA[index].pocCall("open_poccall", pocNo, centerTel);
13742
13841
  },
13743
13842
 
@@ -13761,6 +13860,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13761
13860
  }
13762
13861
 
13763
13862
  me.VIDEO_DATA[index].stream = null;
13863
+ window.pocNo = null;
13764
13864
  return me.VIDEO_DATA[index].pocCall("close_poccall", pocNo, centerTel);
13765
13865
  },
13766
13866
 
@@ -13795,21 +13895,28 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13795
13895
  * 添加事件
13796
13896
  */
13797
13897
  addListener: function (type, handler, key) {
13798
- videoListener.addListener(type, handler, key);
13898
+ this.videoListener.addListener(type, handler, key);
13799
13899
  },
13800
13900
 
13801
13901
  /**
13802
13902
  * 删除事件
13803
13903
  */
13804
13904
  removeListener: function (type, handler) {
13805
- videoListener.removeListener(type, handler);
13905
+ this.videoListener.removeListener(type, handler);
13806
13906
  },
13807
13907
 
13808
13908
  /**
13809
13909
  * 派发事件
13810
13910
  */
13811
13911
  dispatch: function (e, options) {
13812
- videoListener.dispatch(e, options);
13912
+ this.videoListener.dispatch(e, options);
13913
+ },
13914
+
13915
+ /**
13916
+ * 清空事件
13917
+ */
13918
+ removeAllListeners: function () {
13919
+ this.videoListener.removeAllListeners();
13813
13920
  },
13814
13921
 
13815
13922
  /**
@@ -13820,7 +13927,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13820
13927
  index = index || me._opts.windowsBeginIndex;
13821
13928
 
13822
13929
  for (; index < me._opts.windowsBeginIndex + me._opts.windows; index++) {
13823
- if (!me.VIDEO_DATA[index].playing) {
13930
+ if (!me.VIDEO_DATA[index].playing && !me.VIDEO_DATA[index].isWaiting) {
13824
13931
  return index;
13825
13932
  }
13826
13933
  }
@@ -13833,7 +13940,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13833
13940
  */
13834
13941
  _getChoiceWindow: function () {
13835
13942
  let me = this;
13836
- let selView = $('[video-flag="' + me._opts.windowsBeginIndex + '"]>li.sel');
13943
+ let selView = $(me.selector + ' li.sel');
13837
13944
 
13838
13945
  if (selView.length) {
13839
13946
  return selView.index();
@@ -13866,13 +13973,40 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13866
13973
  _clickWindow: function () {
13867
13974
  let me = this; //视频窗口选中
13868
13975
 
13869
- $('[video-flag="' + me._opts.windowsBeginIndex + '"]>li').click(function () {
13870
- $('[video-flag="' + me._opts.windowsBeginIndex + '"]>li').removeClass("sel");
13976
+ $(me.selector + ' li').click(function () {
13977
+ $(me.selector + ' li').removeClass("sel");
13871
13978
  $(this).addClass("sel"); //如果视频正在播放则分发点击消息
13872
13979
 
13873
13980
  if (me.getInChoiceVideo()) {
13874
13981
  me.dispatch('click', me.getInChoiceVideo());
13875
13982
  }
13983
+ }); // 设置视频窗可拖拽
13984
+
13985
+ let src = null;
13986
+ $(me.selector + ' li').bind("dragstart", function (ev) {
13987
+ src = $(this);
13988
+ });
13989
+ $(me.selector + ' li').bind("dragover", function (ev) {
13990
+ ev.preventDefault();
13991
+ });
13992
+ $(me.selector + ' li').bind("drop", function (ev) {
13993
+ ev.preventDefault();
13994
+
13995
+ if (src.prop("outerHTML") === $(this).prop("outerHTML")) {
13996
+ return;
13997
+ }
13998
+
13999
+ let target = $(this);
14000
+ let srcIndex = src.index();
14001
+ let targetIndex = target.index();
14002
+
14003
+ if (srcIndex > targetIndex) {
14004
+ src.insertBefore(target);
14005
+ target.insertAfter($(me.selector + ' .video-main li.screen').eq(srcIndex));
14006
+ } else {
14007
+ src.insertAfter(target);
14008
+ target.insertBefore($(me.selector + ' .video-main li.screen').eq(srcIndex));
14009
+ }
13876
14010
  });
13877
14011
  },
13878
14012
 
@@ -13903,7 +14037,15 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13903
14037
  conf: {},
13904
14038
  pollInterval: 10,
13905
14039
  windowsNum: 16,
13906
- isVideoTag: true //true生成video标签 false生产audio标签 默认true
14040
+ isVideoTag: true,
14041
+ //true生成video标签 false生产audio标签 默认true
14042
+ showVideoInfo: 1,
14043
+ //显示分辨率、码率等信息,1-显示左下角 2-显示左上角,为0时控制_showVideoInfo函数处理,默认1
14044
+ waitPlayQueueSwitch: false,
14045
+ //播放队列开关,默认false
14046
+ defaultBusinessType: 0,
14047
+ // 配置的默认业务类型 0:调度主线 1:勤指
14048
+ videoTipTimeOut: 5 // 超时无首屏检测时间
13907
14049
 
13908
14050
  };
13909
14051
  $.extend(me._opts, opts);
@@ -13930,24 +14072,33 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13930
14072
  } //获取起始的窗口位置
13931
14073
 
13932
14074
 
13933
- me._opts.windowsBeginIndex = windowsSum; //窗口总数
14075
+ me._opts.windowsBeginIndex = 0; // 对讲号码初始化
14076
+
14077
+ window.pocNo = 0; // 播放队列开关 默认打开
14078
+
14079
+ me.waitPlayQueueSwitch = opts.waitPlayQueueSwitch == undefined ? false : opts.waitPlayQueueSwitch; //是否提示
13934
14080
 
13935
- windowsSum += me._opts.windowsNum; //是否提示
14081
+ me._opts.showPrompt === false && (showPrompt = false); // 勤指业务下 设备检测
13936
14082
 
13937
- me._opts.showPrompt === false && (showPrompt = false); //初始化界面
14083
+ me._opts.defaultBusinessType == 1 && me._checkDevices(); //初始化界面
13938
14084
 
13939
- me._opts.isVideoTag ? me._initVideoView($dom) : me._initAudioView($dom); //初始化Janus
14085
+ me._opts.isVideoTag ? me._initVideoView($dom, me._opts.showVideoInfo) : me._initAudioView($dom); //初始化Janus
13940
14086
 
13941
14087
  me._initJanus(); //初始化按钮点击事件
13942
14088
 
13943
14089
 
13944
- me._initBtnEvent(); //设置鼠标点击选中窗口
14090
+ me._initBtnEvent(); // 初始化事件监听
13945
14091
 
13946
14092
 
13947
- me._clickWindow(); //显示视频信息:名称、分辨率、码率、丢包率
14093
+ me._initEventListen(); //设置鼠标点击选中窗口
13948
14094
 
13949
14095
 
13950
- me._showVideoInfo(); //双击某个视频全屏
14096
+ me._clickWindow();
14097
+
14098
+ if (me._opts.showVideoInfo != 0) {
14099
+ //显示视频信息:名称、分辨率、码率、丢包率
14100
+ me._showVideoInfo();
14101
+ } //双击某个视频全屏
13951
14102
 
13952
14103
 
13953
14104
  me._dbClickFullScreen();
@@ -14061,35 +14212,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14061
14212
  * 初始化按钮点击事件
14062
14213
  */
14063
14214
  _initBtnEvent: function () {
14064
- let me = this; // 设置视频窗可拖拽
14065
-
14066
- var src = null;
14067
- $(me.selector + ' li').bind("dragstart", function (ev) {
14068
- src = $(this);
14069
- });
14070
- $(me.selector + ' li').bind("dragover", function (ev) {
14071
- ev.preventDefault();
14072
- });
14073
- $(me.selector + ' li').bind("drop", function (ev) {
14074
- ev.preventDefault();
14075
-
14076
- if (src.prop("outerHTML") === $(this).prop("outerHTML")) {
14077
- return;
14078
- }
14079
-
14080
- var target = $(this);
14081
- var srcIndex = src.index();
14082
- var targetIndex = target.index();
14083
-
14084
- if (srcIndex > targetIndex) {
14085
- src.insertBefore(target);
14086
- target.insertAfter($(me.selector + ' .video-main li.screen').eq(srcIndex));
14087
- } else {
14088
- src.insertAfter(target);
14089
- target.insertBefore($(me.selector + ' .video-main li.screen').eq(srcIndex));
14090
- }
14091
- });
14092
- let videoFlagObj = $('[video-flag="' + me._opts.windowsBeginIndex + '"]'); //锁定视频事件
14215
+ let me = this;
14216
+ let videoFlagObj = $(me.selector + ' .video-main'); //锁定视频事件
14093
14217
 
14094
14218
  videoFlagObj.find("button[name='lockVideo']").click(function () {
14095
14219
  let index = Number($(this).parent().parent().attr("index"));
@@ -14105,7 +14229,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14105
14229
  } else {
14106
14230
  me.VIDEO_DATA[index].isLockVideo = true;
14107
14231
  $(this).attr('class', 'lock-video-btn');
14108
- }
14232
+ } //jquery方式阻止默认事件 & 冒泡事件
14233
+
14234
+
14235
+ return false;
14109
14236
  });
14110
14237
  videoFlagObj.find('button[name=rotateVideo]').click(function () {
14111
14238
  let rotateIndex = Number($(this).attr("rotate-index"));
@@ -14113,13 +14240,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14113
14240
  rotateIndex %= 4;
14114
14241
  $(this).attr("rotate-index", rotateIndex);
14115
14242
  let li = $(this).parent().parent()[0];
14116
- me.videoRotateSize(li, rotateIndex);
14243
+ me.videoRotateSize(li, rotateIndex); //jquery方式阻止默认事件 & 冒泡事件
14244
+
14245
+ return false;
14117
14246
  }); //接收音频事件
14118
14247
 
14119
14248
  videoFlagObj.find("button[name='recvAudio']").click(function () {
14120
14249
  let _self = this;
14121
14250
 
14122
- let index = Number($(this).parent().parent().attr("index"));
14251
+ let index = Number($(this).parent().parent().attr("index")); // 优先当前窗口参数设置的业务类型 其次配置的默认业务类型
14252
+
14253
+ let businessType = me.VIDEO_DATA[index].opts.businessType == undefined ? me._opts.defaultBusinessType : me.VIDEO_DATA[index].opts.businessType;
14123
14254
 
14124
14255
  if (!me.VIDEO_DATA[index].playing) {
14125
14256
  promptAlarm('请选择播放的视频源!');
@@ -14130,65 +14261,112 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14130
14261
  //发送停止播放音频的请求
14131
14262
  me.VIDEO_DATA[index].operateAudio("stop_audio");
14132
14263
  $(this).attr('class', 'unrecv-audio-btn');
14133
- me.VIDEO_DATA[index].tagBox.muted = false;
14264
+ me.VIDEO_DATA[index].tagBox.prop("muted", true);
14134
14265
  } else {
14135
- //发送前先关闭其它音频通道(包括接收和发送音频)
14136
- let lis = $($(_self).parent().parent().parent()).children();
14266
+ if (businessType == 0) {
14267
+ //发送前先关闭其它音频通道(包括接收和发送音频)
14268
+ let lis = $($(_self).parent().parent().parent()).children();
14137
14269
 
14138
- for (let i = 0; i < lis.length; i++) {
14139
- let btnIndex = Number($(lis[i]).attr("index"));
14270
+ for (let i = 0; i < lis.length; i++) {
14271
+ let btnIndex = Number($(lis[i]).attr("index"));
14140
14272
 
14141
- if (index == btnIndex) {
14142
- continue;
14143
- }
14273
+ if (index == btnIndex) {
14274
+ continue;
14275
+ }
14144
14276
 
14145
- let recvBtn = $($(lis[i]).find("button[name='recvAudio']")[0]);
14146
- let sendBtn = $($(lis[i]).find("button[name='sendAudio']")[0]);
14277
+ let recvBtn = $($(lis[i]).find("button[name='recvAudio']")[0]);
14278
+ let sendBtn = $($(lis[i]).find("button[name='sendAudio']")[0]);
14147
14279
 
14148
- if (recvBtn.attr("class") == 'recv-audio-btn') {
14149
- if (me.VIDEO_DATA[btnIndex].playing) {
14150
- recvBtn.click();
14280
+ if (recvBtn.attr("class") == 'recv-audio-btn') {
14281
+ if (me.VIDEO_DATA[btnIndex].playing) {
14282
+ recvBtn.click();
14283
+ }
14151
14284
  }
14152
- }
14153
14285
 
14154
- if (sendBtn.attr("class") == 'send-audio-btn') {
14155
- if (me.VIDEO_DATA[btnIndex].playing) {
14156
- sendBtn.click();
14286
+ if (sendBtn.attr("class") == 'send-audio-btn') {
14287
+ if (me.VIDEO_DATA[btnIndex].playing) {
14288
+ sendBtn.click();
14289
+ }
14157
14290
  }
14158
- }
14159
- } //发送播放音频的请求
14291
+ } //发送播放音频的请求
14160
14292
 
14161
14293
 
14162
- $(_self).attr('class', 'recv-audio-btn');
14163
- setTimeout(function () {
14294
+ $(_self).attr('class', 'recv-audio-btn');
14295
+ setTimeout(function () {
14296
+ if (!me.VIDEO_DATA[index].isClosing) {
14297
+ me.VIDEO_DATA[index].operateAudio("recv_audio");
14298
+ me.VIDEO_DATA[index].tagBox.prop("muted", false);
14299
+ }
14300
+ }, 1000);
14301
+ } else if (businessType == 1) {
14302
+ // poc新模式支持回传多个音频,因此不关闭
14303
+ //发送播放音频的请求
14304
+ $(_self).attr('class', 'recv-audio-btn');
14164
14305
  me.VIDEO_DATA[index].operateAudio("recv_audio");
14165
- me.VIDEO_DATA[index].tagBox.muted = true;
14166
- }, 1000);
14306
+ me.VIDEO_DATA[index].tagBox.prop("muted", false);
14307
+ }
14167
14308
  }
14168
14309
  }); //发送音频事件
14169
14310
 
14170
14311
  videoFlagObj.find("button[name='sendAudio']").click(function () {
14171
- let index = Number($(this).parent().parent().attr("index"));
14312
+ let index = Number($(this).parent().parent().attr("index")); // 优先当前窗口参数设置的业务类型 其次配置的默认业务类型 最后默认调度业务
14313
+
14314
+ let businessType = me.VIDEO_DATA[index].opts.businessType == undefined ? me._opts.defaultBusinessType : me.VIDEO_DATA[index].opts.businessType;
14172
14315
 
14173
14316
  if (!me.VIDEO_DATA[index].playing) {
14174
14317
  promptAlarm('请选择播放的视频源!');
14175
14318
  return;
14176
14319
  }
14177
14320
 
14178
- if ($(this).attr('class') == 'send-audio-btn') {
14179
- me.VIDEO_DATA[index].operateAudio("unsend_audio");
14180
- $(this).attr('class', 'unsend-audio-btn');
14181
- me.VIDEO_DATA[index].stream.getAudioTracks()[0].enabled = false;
14182
- } else {
14183
- me.VIDEO_DATA[index].operateAudio("send_audio");
14184
- $(this).attr('class', 'send-audio-btn');
14185
- me.VIDEO_DATA[index].stream.getAudioTracks()[0].enabled = true;
14186
- }
14321
+ if (businessType == 0) {
14322
+ // 主线业务
14323
+ if ($(this).attr('class') == 'send-audio-btn') {
14324
+ me.VIDEO_DATA[index].operateAudio("unsend_audio");
14325
+ $(this).attr('class', 'unsend-audio-btn');
14326
+ me.VIDEO_DATA[index].stream.getAudioTracks()[0].enabled = false;
14327
+ } else {
14328
+ me.VIDEO_DATA[index].operateAudio("send_audio");
14329
+ $(this).attr('class', 'send-audio-btn');
14330
+ me.VIDEO_DATA[index].stream.getAudioTracks()[0].enabled = true;
14331
+ }
14332
+ } else if (businessType == 1) {
14333
+ // 勤指业务
14334
+ if ($(this).attr('class') == 'send-audio-btn') {
14335
+ $(this).attr('class', 'unsend-audio-btn'); //关闭点对点对讲
14336
+
14337
+ me.VIDEO_DATA[index].ptopPoc("close_ptop_poc", window.pocNo);
14338
+ } else {
14339
+ $(this).attr('class', 'send-audio-btn'); //发起点对点对讲
14340
+
14341
+ me.VIDEO_DATA[index].ptopPoc("open_ptop_poc", window.pocNo);
14342
+ }
14343
+ } //jquery方式阻止默认事件 & 冒泡事件
14344
+
14345
+
14346
+ return false;
14187
14347
  }); //关闭视频事件
14188
14348
 
14189
14349
  videoFlagObj.find("button[name='closeVideo']").click(function () {
14190
14350
  let index = Number($(this).parent().parent().attr("index"));
14191
- me.close(index);
14351
+ me.close(index); // //jquery方式阻止默认事件 & 冒泡事件
14352
+ // return false;
14353
+ });
14354
+ },
14355
+
14356
+ /**
14357
+ * 初始化事件监听
14358
+ */
14359
+ _initEventListen: function () {
14360
+ let _self = this; // 打开视频 {index, video, id, opts} index(视频窗口编号,从0开始) video(视频设备id,即devId) id(标识,空的话使用设备id) opts(其他参数)
14361
+
14362
+
14363
+ _self.addListener('openVideo', function (e) {
14364
+ _self.play(e.index, e.video, e.id, e.opts);
14365
+ }); // janus通知后台已关闭视频
14366
+
14367
+
14368
+ _self.addListener('notifyCloseVideo', function (e) {
14369
+ _self._notifyWaitingVideo(e.index);
14192
14370
  });
14193
14371
  },
14194
14372
 
@@ -14197,7 +14375,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14197
14375
  */
14198
14376
  _dbClickFullScreen: function () {
14199
14377
  let me = this;
14200
- $('[video-flag="' + me._opts.windowsBeginIndex + '"]').find('.video-box').on("dblclick", function () {
14378
+ $(me.selector + ' .video-main').find('.video-box').on("dblclick", function () {
14201
14379
  me._fullScreenEvent(this);
14202
14380
  });
14203
14381
  },
@@ -14232,10 +14410,20 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14232
14410
  let me = this;
14233
14411
 
14234
14412
  function clock() {
14413
+ if (!me.VIDEO_DATA || !me.VIDEO_DATA.length) return;
14414
+
14235
14415
  for (let i = 0; i < me.VIDEO_DATA.length; i++) {
14236
14416
  if (me.VIDEO_DATA[i].playing) {
14237
- let number = Number(i) + Number(1);
14238
- let videoObj = document.getElementById('video-' + number);
14417
+ let number = Number(i) + Number(1); //获取视频video标签
14418
+
14419
+ let $videoList = $(me.selector + " .video-main #video-" + number);
14420
+
14421
+ if (!$videoList.length) {
14422
+ console.error("can not find dom by id [video-" + number + "]");
14423
+ continue;
14424
+ }
14425
+
14426
+ let videoObj = $videoList[0];
14239
14427
  if (!videoObj) continue;
14240
14428
  let width = videoObj.videoWidth;
14241
14429
  let height = videoObj.videoHeight; //码率
@@ -14250,6 +14438,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14250
14438
 
14251
14439
  me._setPacketsLostRate(i, config, me);
14252
14440
 
14441
+ me._setFrameDecoded(i, config, me);
14442
+
14253
14443
  let resolution = width + "×" + height;
14254
14444
 
14255
14445
  switch (height + '') {
@@ -14271,11 +14461,26 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14271
14461
 
14272
14462
  default:
14273
14463
  break;
14464
+ } //获取文案显示dom元素
14465
+
14466
+
14467
+ let $videoInfoList = $(me.selector + " .video-main #info-" + number);
14468
+
14469
+ if (!$videoInfoList.length) {
14470
+ console.error("can not find dom by id [info-" + number + "]");
14471
+ continue;
14274
14472
  }
14275
14473
 
14276
- let videoInfoObj = document.getElementById('info-' + number);
14474
+ let videoInfoObj = $videoInfoList[0];
14277
14475
  let videoName = me.VIDEO_DATA[i].opts && me.VIDEO_DATA[i].opts.name ? me.VIDEO_DATA[i].opts.name : me.VIDEO_DATA[i].video;
14278
- videoInfoObj.innerHTML = videoName + '&nbsp;&nbsp;' + resolution + '<br>丢包率:' + me.VIDEO_DATA[i].packetsLostRate + '&nbsp;&nbsp;' + bitrate.replace("kbits/sec", "kbps");
14476
+ videoInfoObj.innerHTML = videoName + '&nbsp;&nbsp;' + resolution + '<br>丢包率:' + me.VIDEO_DATA[i].packetsLostRate + '&nbsp;&nbsp;' + bitrate.replace("kbits/sec", "kbps"); //根据视频框大小自动计算 显示文案的文字大小
14477
+
14478
+ let fontHeightSize = $(me.selector + " .video-main #video-" + number).height() / 15;
14479
+ let fontWidthSize = $(me.selector + " .video-main #video-" + number).width() / 18; //长和宽 除以 15, 取小的值做文字大小样式
14480
+
14481
+ let fontSize = fontHeightSize < fontWidthSize ? fontHeightSize : fontWidthSize;
14482
+ fontSize = !fontSize || fontSize > 20 ? 20 : fontSize;
14483
+ $("#info-" + number).css("font-size", fontSize + "px");
14279
14484
  }
14280
14485
  }
14281
14486
  } //已存在则清除
@@ -14338,17 +14543,175 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14338
14543
  }
14339
14544
  },
14340
14545
 
14546
+ /**
14547
+ * 设置当前网络信号提示
14548
+ * @param index 当前打开视频的索引
14549
+ * @param config
14550
+ * @param me
14551
+ * @private
14552
+ */
14553
+ _setFrameDecoded: function (index, config, me) {
14554
+ if (config.pc !== null && typeof config.pc !== 'undefined' && config.pc.getStats) {
14555
+ config.pc.getStats().then(function (stats) {
14556
+ stats.forEach(function (res) {
14557
+ if (res) {
14558
+ let inStats = false; // Check if these are statistics on incoming media
14559
+
14560
+ if ((res.mediaType === 'video' || res.id.toLowerCase().indexOf('video') > -1) && res.type === 'inbound-rtp' && res.id.indexOf('rtcp') < 0) {
14561
+ // New stats
14562
+ inStats = true;
14563
+ } else if (res.type === 'ssrc' && res.bytesReceived && (res.googCodecName === 'VP8' || res.googCodecName === '')) {
14564
+ // Older Chromer versions
14565
+ inStats = true;
14566
+ } // Parse stats now
14567
+
14568
+
14569
+ if (inStats) {
14570
+ if (res.hasOwnProperty('framesDecoded')) {
14571
+ if (res.framesDecoded <= 1) return;
14572
+
14573
+ if (typeof me.VIDEO_DATA[index].framesDecodedCount === 'undefined') {
14574
+ me.VIDEO_DATA[index].framesDecodedCount = 0;
14575
+ }
14576
+
14577
+ if (typeof me.VIDEO_DATA[index].framesDecodedLast === 'undefined') {
14578
+ me.VIDEO_DATA[index].framesDecodedLast = res.framesDecoded;
14579
+ }
14580
+
14581
+ if (res.framesDecoded > me.VIDEO_DATA[index].framesDecodedLast) {
14582
+ if (typeof me.VIDEO_DATA[index].tipDom !== 'undefined' && me.VIDEO_DATA[index].tipDom.style.display === 'block') {
14583
+ me.VIDEO_DATA[index].tipDom.style.display = 'none';
14584
+ }
14585
+ }
14586
+
14587
+ me.VIDEO_DATA[index].framesDecodedCount++; // 定时检测
14588
+
14589
+ if (me.VIDEO_DATA[index].framesDecodedCount === me.configOpt) {
14590
+ if (res.framesDecoded - me.VIDEO_DATA[index].framesDecodedLast === 0) {
14591
+ // 卡顿
14592
+ if (typeof me.VIDEO_DATA[index].tipDom === 'undefined') {
14593
+ var numIndex = index + 1;
14594
+ me.VIDEO_DATA[index].tipDom = document.getElementById('frame-decoded-' + numIndex);
14595
+ }
14596
+
14597
+ me.VIDEO_DATA[index].tipDom.style.display = 'block';
14598
+ }
14599
+
14600
+ me.VIDEO_DATA[index].framesDecodedCount = 0;
14601
+ me.VIDEO_DATA[index].framesDecodedLast = res.framesDecoded;
14602
+ } else {
14603
+ me.VIDEO_DATA[index].framesDecodedLast = res.framesDecoded;
14604
+ }
14605
+ }
14606
+ }
14607
+ }
14608
+ });
14609
+ });
14610
+ }
14611
+ },
14612
+
14613
+ /**
14614
+ * 设备可用性检查(扬声器、麦克风、分辨率、浏览器类型)
14615
+ * 1. 未检测(status == undefined)询问进入检测界面
14616
+ * 2. 检测完成按相应结果给予相应提示
14617
+ * 3. 拒绝检测按所有检测通过处理
14618
+ * 4. 程序自行检测,并将是否加载声卡结果放入window对象
14619
+ * @private
14620
+ */
14621
+ _checkDevices: function () {
14622
+ let me = this;
14623
+ let tipCountKey = "DEVICES_CHECK_TIP_COUNT";
14624
+ let statusKey = "DEVICES_CHECK_STATUS";
14625
+ let checkCompleted = "completed";
14626
+ let checkRejected = "rejected";
14627
+ let microResultKey = "MICRO_RESULT";
14628
+ let speakerResultKey = "SPEAKER_RESULT";
14629
+ let screenResultKey = "SCREEN_RESULT";
14630
+ let resultPass = "pass";
14631
+ let resultNotPass = "not pass";
14632
+ let tipCount = sessionStorage.getItem(tipCountKey);
14633
+ let status = localStorage.getItem(statusKey);
14634
+
14635
+ if ((tipCount == undefined || tipCount == "0") && status == undefined) {
14636
+ sessionStorage.setItem(tipCountKey, "1"); //弹窗讯问是否进入检测界面
14637
+
14638
+ if (confirm("您还没有检测硬件设备,是否先进行检测?")) {
14639
+ window.open("/scooper-video/new/checkDevices");
14640
+ } else {
14641
+ localStorage.setItem(statusKey, checkRejected);
14642
+ }
14643
+
14644
+ return;
14645
+ }
14646
+
14647
+ if (status == checkCompleted) {
14648
+ let microResult = localStorage.getItem(microResultKey) == undefined ? resultPass : localStorage.getItem(microResultKey);
14649
+ let speakerResult = localStorage.getItem(speakerResultKey) == undefined ? resultPass : localStorage.getItem(speakerResultKey);
14650
+ let screenResult = localStorage.getItem(screenResultKey) == undefined ? resultPass : localStorage.getItem(screenResultKey);
14651
+ let msg = "";
14652
+
14653
+ if (speakerResult == resultNotPass) {
14654
+ msg += "检测到扬声器异常,可能影响系统某些功能的使用!";
14655
+ console.error(msg);
14656
+ }
14657
+
14658
+ if (microResult == resultNotPass) {
14659
+ msg += "检测到麦克风异常,可能影响系统某些功能的使用!";
14660
+ console.error(msg);
14661
+ }
14662
+
14663
+ if (screenResult === resultNotPass) {
14664
+ msg += "您的屏幕分辨率过低,可能导致页面布局混乱!"; //提示消息
14665
+
14666
+ promptAlarm(msg);
14667
+ }
14668
+
14669
+ let userAgent = navigator.userAgent;
14670
+
14671
+ if (userAgent.toLowerCase().indexOf("chrome") < 0 && userAgent.toLowerCase().indexOf("firefox") < 0 && userAgent.toLowerCase().indexOf("edge") < 0) {
14672
+ msg += "当前浏览器下部分功能可能存在兼容问题,建议使用谷歌浏览器!";
14673
+ promptAlarm(msg);
14674
+ }
14675
+
14676
+ if (msg != "") {
14677
+ //提示并派发消息
14678
+ // promptAlarm(msg);
14679
+ //防止外部未监听消息就派发事件
14680
+ setTimeout(function () {
14681
+ me.videoListener.dispatch('msginfo', {
14682
+ 'msg': msg
14683
+ });
14684
+ }, 3000);
14685
+ }
14686
+ }
14687
+ },
14688
+
14341
14689
  /**
14342
14690
  * 视频界面的初始化,在传过来的dom中创建界面
14343
14691
  */
14344
- _initVideoView: function ($dom) {
14692
+ _initVideoView: function ($dom, infoPosition) {
14345
14693
  let me = this;
14346
- let objClass = (me._opts.windowsNum == 1 ? 'video-main-full mode-' : 'video-main mode-') + me._opts.windows;
14694
+ let position;
14695
+
14696
+ switch (infoPosition) {
14697
+ case 1:
14698
+ position = "info-bottom";
14699
+ break;
14700
+
14701
+ case 2:
14702
+ position = "info-top";
14703
+ break;
14704
+
14705
+ default:
14706
+ position = "info-bottom";
14707
+ }
14708
+
14709
+ let objClass = (me._opts.windowsNum == 1 ? 'video-main video-main-full mode-' : 'video-main mode-') + me._opts.windows;
14347
14710
  let videoHtml = '<ul class="' + objClass + '" id="video-main-web-rtc" video-flag="' + me._opts.windowsBeginIndex + '">';
14348
14711
  let index = me._opts.windowsBeginIndex + 1;
14349
14712
 
14350
14713
  for (let i = index; i < index + me._opts.windowsNum; i++) {
14351
- videoHtml += '<li class="screen-' + i + '" index="' + (i - 1) + '" draggable="true"><video class="video-box" id="video-' + i + '" autoplay ></video>' + '<div class="info hide" id="info-' + i + '"></div>' + '<div class="operate-btn">'; //videoHtml +='<button type="button" class="unlock-video-btn hide" name="lockVideo"></button>';
14714
+ videoHtml += '<li class="screen screen-' + i + '" index="' + (i - 1) + '" draggable="true"><video muted class="video-box" id="video-' + i + '" autoplay ></video>' + '<div class="hide info ' + position + '" id="info-' + i + '"></div>' + '<div class="hide frame-decoded" id="frame-decoded-' + i + '"style="position:absolute;float:left;color:#fff;width:67%;z-index:1;top:135px;left:180px">网络信号不佳</div>' + '<div class="operate-btn">'; //videoHtml +='<button type="button" class="unlock-video-btn hide" name="lockVideo"></button>';
14352
14715
 
14353
14716
  checkUserMediaAvailable() && (videoHtml += '<button type="button" class="rotate-btn hide" name="rotateVideo" rotate-index="0" title="视频旋转"></button><button type="button" class="unsend-audio-btn hide" name="sendAudio"></button>');
14354
14717
  videoHtml += '<button type="button" class="unrecv-audio-btn hide" name="recvAudio"></button>' + '<button type="button" class="close-btn hide" name="closeVideo"></button>' + '</div>' + '</li>';
@@ -14364,7 +14727,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14364
14727
  */
14365
14728
  _initAudioView: function ($dom) {
14366
14729
  let me = this;
14367
- let objClass = (me._opts.windowsNum == 1 ? 'video-main-full mode-' : 'video-main mode-') + me._opts.windows;
14730
+ let objClass = (me._opts.windowsNum == 1 ? 'video-main video-main-full mode-' : 'video-main mode-') + me._opts.windows;
14368
14731
  let videoHtml = '<ul class="' + objClass + '" id="video-main-web-rtc" video-flag="' + me._opts.windowsBeginIndex + '">';
14369
14732
  let index = me._opts.windowsBeginIndex + 1;
14370
14733
 
@@ -14414,6 +14777,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14414
14777
  console.error('Janus服务连接失败:' + error);
14415
14778
  me.closeAll();
14416
14779
 
14780
+ me._removeAllWaitingVideo();
14781
+
14417
14782
  me._initJanus();
14418
14783
  },
14419
14784
  destroyed: function () {
@@ -14424,6 +14789,19 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14424
14789
  });
14425
14790
  },
14426
14791
 
14792
+ /**
14793
+ * 销毁所有
14794
+ */
14795
+ destory: function () {
14796
+ var me = this;
14797
+ me.destoryJanus();
14798
+ $(me.selector).empty();
14799
+ me.videoListener = null;
14800
+ me.VIDEO_DATA = null;
14801
+ me.selector = null; //destoryJanus会触发回调,需要使用到opts
14802
+ // me._opts = null;
14803
+ },
14804
+
14427
14805
  /**
14428
14806
  * 销毁:Janus销毁、资源释放
14429
14807
  */
@@ -14432,14 +14810,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14432
14810
 
14433
14811
  me._opts.janus.destroy({
14434
14812
  success: function () {
14435
- window.windowsSum = 0; //userToken = null;
14436
-
14813
+ // window.windowsSum = 0;
14814
+ //userToken = null;
14437
14815
  registered = false;
14438
14816
  },
14439
14817
  asyncRequest: true,
14440
14818
  notifyDestroyed: true
14441
14819
  });
14820
+
14821
+ me.removeAllListeners();
14442
14822
  },
14823
+ reLoginJanusItvIndex: -1,
14443
14824
 
14444
14825
  /**
14445
14826
  * 初始化插件、登陆,初始化窗口
@@ -14499,13 +14880,43 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14499
14880
 
14500
14881
  if (event === 'registration_failed') {
14501
14882
  promptFailed("janus登陆失败: " + result["code"] + " " + result["reason"]);
14883
+
14884
+ if (me.reLoginJanusItvIndex == -1) {
14885
+ me.reLoginJanusItvIndex = setInterval(function () {
14886
+ console.log("尝试重新登陆janus!");
14887
+
14888
+ me._initJanus(janus);
14889
+ }, 5000);
14890
+ }
14891
+
14892
+ return;
14893
+ }
14894
+
14895
+ if (event === 'video_server_closed') {
14896
+ if (me.reLoginJanusItvIndex == -1) {
14897
+ me.reLoginJanusItvIndex = setInterval(function () {
14898
+ console.log("尝试重新登陆janus!");
14899
+
14900
+ me._initJanus(janus);
14901
+ }, 5000);
14902
+ }
14903
+
14502
14904
  return;
14503
14905
  }
14504
14906
 
14505
14907
  if (event === 'registered') {
14506
14908
  let userToken = result["userToken"];
14507
14909
  console.log('janus登陆成功');
14508
- registered = true; //生成主界面
14910
+ registered = true;
14911
+
14912
+ if (me.reLoginJanusItvIndex != -1) {
14913
+ clearInterval(me.reLoginJanusItvIndex);
14914
+ me.reLoginJanusItvIndex = -1;
14915
+ } //生成主界面
14916
+ //相对序号,用于标识当前janus连接初始化的序号窗口
14917
+
14918
+
14919
+ let relativeIndex = 0;
14509
14920
 
14510
14921
  for (let i = me._opts.windowsBeginIndex; i < me._opts.windowsBeginIndex + me._opts.windowsNum; i++) {
14511
14922
  me.VIDEO_DATA[i] = new SVideo({
@@ -14513,42 +14924,254 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14513
14924
  janus: janus,
14514
14925
  userToken: userToken,
14515
14926
  windowsNum: me._opts.windowsNum,
14927
+ relativeIndex: relativeIndex++,
14516
14928
  flag: me._opts.flag,
14517
14929
  isVideoTag: me._opts.isVideoTag,
14518
- janusPlugin: me._opts.conf.janusPlugin
14519
- });
14930
+ janusPlugin: me._opts.conf.janusPlugin,
14931
+ videoTipTimeOut: me._opts.videoTipTimeOut,
14932
+ parentSelector: me.selector
14933
+ }, me.videoListener);
14520
14934
  }
14521
14935
  }
14522
14936
  }
14523
14937
  }
14524
14938
  });
14939
+ },
14940
+
14941
+ /* ----------------------------- 播放队列 --------------------------- */
14942
+ // 记录等待中的视频
14943
+ WAITING_DATA: [],
14944
+ // 播放队列开关 默认关闭
14945
+ waitPlayQueueSwitch: false,
14946
+
14947
+ /**
14948
+ * 添加等待视频数据
14949
+ * 同一位置再次打开,则覆盖上一次的
14950
+ * 参数:index(视频窗口编号,从0开始) video(视频设备id,即devId) id(标识,空的话使用设备id) opts(其他参数)
14951
+ */
14952
+ _addWaitingVideo: function (index, video, id, opts) {
14953
+ let _self = this;
14954
+
14955
+ let isOverride = false;
14956
+ $.each(_self.WAITING_DATA, function (i, obj) {
14957
+ if (obj.index == index) {
14958
+ console.log("播放队列中 index = " + index + ", video = " + obj.video + " 替换为 video = " + video);
14959
+ _self.WAITING_DATA[i] = {
14960
+ index: index,
14961
+ video: video,
14962
+ id: id,
14963
+ opts: opts
14964
+ };
14965
+ isOverride = true;
14966
+ return false;
14967
+ }
14968
+ });
14969
+
14970
+ if (!isOverride) {
14971
+ _self.WAITING_DATA.push({
14972
+ index: index,
14973
+ video: video,
14974
+ id: id,
14975
+ opts: opts
14976
+ });
14977
+
14978
+ console.log("index = " + index + ", video = " + video + " 加入播放队列");
14979
+ }
14980
+
14981
+ _self.VIDEO_DATA[index].isWaiting = true;
14982
+ },
14983
+
14984
+ /**
14985
+ * 删除等待视频数据
14986
+ */
14987
+ _removeWaitingVideo: function (index, video) {
14988
+ let _self = this;
14989
+
14990
+ $.each(_self.WAITING_DATA, function (i, obj) {
14991
+ if (obj.index == index && obj.video == video) {
14992
+ _self.WAITING_DATA.splice(i, 1);
14993
+
14994
+ _self.VIDEO_DATA[index].isWaiting = false;
14995
+ console.log("index = " + index + ", video = " + video + " 从播放队列移除");
14996
+ return false;
14997
+ }
14998
+ });
14999
+ },
15000
+
15001
+ /**
15002
+ * 删除所有等待播放视频的数据
15003
+ */
15004
+ _removeAllWaitingVideo: function () {
15005
+ let _self = this;
15006
+
15007
+ _self.WAITING_DATA = [];
15008
+ let index = _self._opts.windowsBeginIndex;
15009
+
15010
+ for (; index < _self._opts.windowsBeginIndex + _self._opts.windows; index++) {
15011
+ _self.VIDEO_DATA[index].isWaiting = false;
15012
+ }
15013
+ },
15014
+
15015
+ /**
15016
+ * 上一个视频关闭后,如果该位置由等待视频,通知打开新视频
15017
+ * @param index
15018
+ */
15019
+ _notifyWaitingVideo: function (index) {
15020
+ let _self = this;
15021
+
15022
+ $.each(_self.WAITING_DATA, function (i, obj) {
15023
+ if (obj.index == index) {
15024
+ _self.play(obj.index, obj.video, obj.id, obj.opts);
15025
+
15026
+ _self._removeWaitingVideo(obj.index, obj.video);
15027
+
15028
+ return false;
15029
+ }
15030
+ });
14525
15031
  }
14526
15032
  };
14527
- let FAILED_CODE = {
14528
- 1001: "账号或密码错误",
14529
- 1002: "该帐号已连接",
14530
- 1004: "没有鉴权",
14531
- 2001: "未携带token或token错误",
14532
- 2002: "视频源id不存在",
14533
- 2003: "操作指令非法(该账号不允许执行这个指令,或者不支持该指令)",
14534
- 3001: "nat通道未建立",
14535
- 3002: "该视频流已在传输",
14536
- 3003: "无法获取远端视频流",
14537
- 4001: "视频流断开连接",
14538
- 4002: "获取视频失败",
14539
- 5000: "内部错误",
14540
- 8001: "设备不支持该指令",
14541
- 453: "videoServer连接失败",
14542
- 454: "录像回放窗口已占用,请先停止播放",
14543
- 455: "无视频录像,操作失败",
14544
- 5001: "呼叫异常断开",
14545
- 5002: "禁止修改分辨率",
14546
- 4003: "音频被占用",
14547
- 4004: "音频被占用",
14548
- 4005: "客户端已打开对讲",
14549
- 4006: "终端离开云眼音频"
15033
+ let CONST_CODE = {
15034
+ //打开失败错误码,面板显示,不做浮窗提示框显示
15035
+ VIDEO_CODE: {
15036
+ 2002: "打开失败,未找到该ID的视频源",
15037
+ 2003: "打开失败,请确认视频服务版本",
15038
+ 3001: "打开失败,未接收到引流包,请检查端口映射",
15039
+ 3002: "",
15040
+ 3003: "打开失败,对方拒绝视频请求",
15041
+ 4001: "打开失败,视频流中断",
15042
+ 4002: "打开失败,终端挂机或超时未接听",
15043
+ 7000: "打开失败,无法连接视频设备",
15044
+ 7001: "打开失败,无法连接视频设备",
15045
+ 7002: "打开失败,无法连接视频设备"
15046
+ },
15047
+ OTHER_CODE: {
15048
+ 453: "videoServer连接失败,错误码453",
15049
+ 454: "视频窗口已被占用,请选择其它窗口打开或停止播放",
15050
+ 455: "操作失败,该段时间无视频录像",
15051
+ 499: "操作异常,错误码499",
15052
+ 440: "操作异常,错误码440",
15053
+ 441: "操作异常,错误码441",
15054
+ 442: "操作异常,错误码442",
15055
+ 443: "操作异常,错误码443",
15056
+ 444: "操作异常,错误码444",
15057
+ 445: "操作异常,错误码445",
15058
+ 446: "操作异常,错误码446",
15059
+ 447: "操作异常,错误码447",
15060
+ 448: "操作异常,错误码448",
15061
+ 449: "操作异常,错误码449",
15062
+ 450: "操作异常,错误码450",
15063
+ 451: "操作异常,错误码451",
15064
+ 452: "操作异常,错误码452",
15065
+ 456: "设备已处于对讲状态或不支持对讲",
15066
+ 6001: "录像失败"
15067
+ },
15068
+ FAILED_CODE: {
15069
+ 1001: "账号或密码错误",
15070
+ 1002: "该帐号已连接",
15071
+ 1004: "没有鉴权",
15072
+ 2001: "未携带token或token错误",
15073
+ 2002: "视频源id不存在",
15074
+ 2003: "操作指令非法(该账号不允许执行这个指令,或者不支持该指令)",
15075
+ 3001: "nat通道未建立",
15076
+ 3002: "该视频流已在传输",
15077
+ 3003: "无法获取远端视频流",
15078
+ 4001: "视频流异常断开连接",
15079
+ 4002: "获取视频失败",
15080
+ 5000: "内部错误",
15081
+ 8001: "该设备不支持云台操作",
15082
+ 453: "videoServer连接失败",
15083
+ 454: "录像回放窗口已占用,请先停止播放",
15084
+ 455: "无视频录像,操作失败",
15085
+ 5001: "呼叫异常断开",
15086
+ 5002: "禁止修改分辨率",
15087
+ 401: "禁止修改分辨率",
15088
+ 4003: "音频重置",
15089
+ 4004: "音频被占用",
15090
+ 4005: "客户端已打开对讲",
15091
+ 4006: "终端离开云眼音频",
15092
+ 4008: "终端拒绝打开视频",
15093
+ 6001: "录像失败",
15094
+ 499: "内部创建失败",
15095
+ 440: "请求消息内容为空",
15096
+ 441: "json格式错误",
15097
+ 442: "无效的请求",
15098
+ 443: "消息内容缺失",
15099
+ 444: "消息缺少参数",
15100
+ 445: "账户已登陆",
15101
+ 446: "收到的videoserver消息有误",
15102
+ 447: "消息参数错误",
15103
+ 448: "SDP创建失败",
15104
+ 449: "未使用",
15105
+ 450: "创建端口失败",
15106
+ 451: "SDP创建失败",
15107
+ 452: "未使用加密的RTP",
15108
+ 456: "对讲未打开",
15109
+ 7000: "URL账号密码错误(RTSP)",
15110
+ 7001: "URL地址不通(RTSP)",
15111
+ 7002: "URL格式错误(RTSP)"
15112
+ },
15113
+ STATUS_CODE_ARR: ['5002', '4003', '4004', '4005', '4006']
14550
15114
  };
14551
- let STATUS_CODE_ARR = ['5002', '4003', '4004', '4005', '4006']; //window.VIDEO_DATA = [];//记录视频各分屏的状态
15115
+ /**
15116
+ * 显示播放错误内容, 4002特殊处理
15117
+ * @param videoObj 视频对象
15118
+ * @param code 状态码(包含错误码)
15119
+ * @param isShowReplayBtn 是否显示重新播放按钮
15120
+ * @param video 打开错误的视频Id
15121
+ */
15122
+
15123
+ function showResult(videoObj, code, isShowReplayBtn, video) {
15124
+ let videoDom = videoObj.tagBox.parent();
15125
+ videoDom.addClass("result");
15126
+ videoDom.find('.operate-btn .close-btn').show();
15127
+
15128
+ if (CONST_CODE.FAILED_CODE[code] && code != "4002") {
15129
+ let resultHtml = "<div class='real-result'>错误码" + code + ": " + CONST_CODE.FAILED_CODE[code] + "</div>";
15130
+ videoDom.append(resultHtml);
15131
+ }
15132
+
15133
+ let resultHtml = "<div class='result'><div class='result-tip'>" + CONST_CODE.VIDEO_CODE[code] + "</div>";
15134
+
15135
+ if (isShowReplayBtn && code != "4002") {
15136
+ resultHtml += "<div class='result-replay'><span id='replay-" + videoObj.index + "' class='replay'>点击重试</span></div>";
15137
+ }
15138
+
15139
+ resultHtml += "</div>";
15140
+ videoDom.append(resultHtml);
15141
+
15142
+ if (isShowReplayBtn && code != "4002") {
15143
+ $("#replay-" + videoObj.index).unbind("click").click(function () {
15144
+ videoObj.videoListener.dispatch("openVideo", {
15145
+ index: videoObj.index,
15146
+ video: video,
15147
+ id: videoObj.id,
15148
+ opts: videoObj.opts
15149
+ });
15150
+ });
15151
+ }
15152
+
15153
+ if (code == "4002") {
15154
+ setTimeout(function () {
15155
+ clearResult(videoDom);
15156
+ }, 5000);
15157
+ }
15158
+ }
15159
+ /**
15160
+ * 清除显示内容 videoDom: 视频Dom对象
15161
+ */
15162
+
15163
+
15164
+ function clearResult(videoDom, videoObj) {
15165
+ videoDom.removeClass("result");
15166
+ videoDom.find(".real-result").remove();
15167
+ videoDom.find(".result").remove();
15168
+
15169
+ if (!videoObj || !videoObj.playing) {
15170
+ // bug id 18654: 增加是否正在播放判断
15171
+ videoDom.find('.operate-btn .close-btn').hide();
15172
+ }
15173
+ } //window.VIDEO_DATA = [];//记录视频各分屏的状态
15174
+
14552
15175
 
14553
15176
  window.windowsSum = 0; //当前页面的视频总数,可能有多个VideoWebRtc对象
14554
15177
  //let userToken = null;
@@ -14556,16 +15179,27 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14556
15179
  let registered = false;
14557
15180
  let recordAvBusinessId = null;
14558
15181
 
14559
- function SVideo(opts) {
15182
+ function SVideo(opts, videoListener) {
14560
15183
  this.janus = opts.janus;
14561
15184
  this.userToken = opts.userToken;
14562
15185
  this.sipcall = null;
14563
15186
  this.index = opts.index;
14564
- this.tagBox = opts.isVideoTag ? $('#video-' + (this.index + 1)) : $('#audio-' + (this.index + 1));
15187
+ this.relativeIndex = opts.relativeIndex; // this.tagBox = opts.isVideoTag ? $('#video-' + (this.index + 1)) : $('#audio-' + (this.index + 1));
15188
+
15189
+ this.tagBox = opts.isVideoTag ? $(opts.parentSelector + ' #video-' + (this.index + 1)) : $('#audio-' + (this.index + 1));
14565
15190
  this.windowsNum = opts.windowsNum;
14566
15191
  this.flag = opts.flag;
14567
15192
  this.isVideoTag = opts.isVideoTag;
14568
15193
  this.janusPlugin = opts.janusPlugin;
15194
+ this.isClosing = false; // 当前分屏是否正在关闭视频
15195
+
15196
+ this.isWaiting = false; // 当前分屏是否有视频在等待播放
15197
+
15198
+ this.playSucTimeOutIndex = -1; // 超时提示定时器index
15199
+
15200
+ this.videoTipTimeOut = opts.videoTipTimeOut; // 超时无首屏时间
15201
+
15202
+ this.videoListener = videoListener;
14569
15203
  this.init();
14570
15204
  }
14571
15205
  /**
@@ -14586,8 +15220,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14586
15220
  console.log("视频插件初始化成功:" + self.index);
14587
15221
  self.sipcall = pluginHandle;
14588
15222
 
14589
- if (self.index + 1 >= self.windowsNum) {
14590
- videoListener.dispatch('initsucc', self);
15223
+ if (self.relativeIndex + 1 >= self.windowsNum) {
15224
+ self.videoListener.dispatch('initsucc', self);
14591
15225
  }
14592
15226
  },
14593
15227
  error: function (error) {
@@ -14601,11 +15235,20 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14601
15235
  promptFailed("请先登陆");
14602
15236
  }
14603
15237
 
15238
+ let video = self.video;
15239
+
14604
15240
  if (msg.error_code) {
14605
- console.error(msg.error_code + ' ' + msg.error);
14606
- promptFailed(FAILED_CODE[msg.error_code] || '错误码:' + msg.error_code);
14607
- videoListener.dispatch('msginfo', {
14608
- 'msg': FAILED_CODE[msg.error_code] || '错误码:' + msg.error_code
15241
+ console.error("错误码:" + msg.error_code + " " + CONST_CODE.FAILED_CODE[msg.error_code]);
15242
+
15243
+ if (CONST_CODE.VIDEO_CODE[msg.error_code]) {
15244
+ showResult(self, msg.error_code, true, video);
15245
+ } else {
15246
+ promptFailed(CONST_CODE.OTHER_CODE[msg.error_code] || CONST_CODE.FAILED_CODE[msg.error_code] || '错误码:' + msg.error_code);
15247
+ }
15248
+
15249
+ self.videoListener.dispatch('msginfo', {
15250
+ 'code': msg.error_code,
15251
+ 'msg': CONST_CODE.OTHER_CODE[msg.error_code] || CONST_CODE.FAILED_CODE[msg.error_code] || '错误码:' + msg.error_code
14609
15252
  });
14610
15253
  return false;
14611
15254
  }
@@ -14615,23 +15258,32 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14615
15258
 
14616
15259
  if (result.error_code && result.error_code != 0) {
14617
15260
  //videoListener.dispatch('afterclose', self);
14618
- if (!STATUS_CODE_ARR.includes(result.error_code + '')) {
15261
+ if (!CONST_CODE.STATUS_CODE_ARR.includes(result.error_code + '')) {
14619
15262
  //videoListener.dispatch('afterclose', self);
14620
15263
  //播放失败 关闭视频
14621
- let video = self.video;
14622
15264
  self.close('err');
14623
15265
 
14624
15266
  if (self.isLockVideo) {
14625
- self.play(video);
15267
+ setTimeout(function () {
15268
+ self.play(video);
15269
+ }, 1500);
14626
15270
  } else {
14627
- videoListener.dispatch('afterclose', self);
15271
+ self.closeType = 'error';
15272
+ self.videoListener.dispatch('afterclose', self);
14628
15273
  }
14629
15274
  }
14630
15275
 
14631
- videoListener.dispatch('msginfo', {
14632
- 'msg': FAILED_CODE[result.error_code] || '错误码:' + result.error_code
15276
+ self.videoListener.dispatch('msginfo', {
15277
+ 'code': result.error_code,
15278
+ 'msg': CONST_CODE.OTHER_CODE[result.error_code] || CONST_CODE.FAILED_CODE[result.error_code] || '错误码:' + result.error_code
14633
15279
  });
14634
- promptFailed(FAILED_CODE[result.error_code] || '错误码:' + result.error_code);
15280
+
15281
+ if (CONST_CODE.VIDEO_CODE[result.error_code]) {
15282
+ showResult(self, result.error_code, true, video);
15283
+ } else {
15284
+ promptFailed(CONST_CODE.OTHER_CODE[result.error_code] || CONST_CODE.FAILED_CODE[result.error_code] || '错误码:' + result.error_code);
15285
+ }
15286
+
14635
15287
  self.tagBox.parent().find('.recv-audio-btn').attr("class", "unrecv-audio-btn");
14636
15288
  self.tagBox.parent().find('.send-audio-btn').attr("class", "unsend-audio-btn");
14637
15289
  } //事件响应
@@ -14664,17 +15316,19 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14664
15316
  });
14665
15317
  },
14666
15318
  error: function (error) {
14667
- console.error(error);
14668
- let body = {
14669
- "request": "decline",
14670
- "code": 480
14671
- };
14672
- self.sipcall.send({
14673
- "message": body
14674
- });
15319
+ console.error(error); // let body = { "request": "decline", "code": 480 };
15320
+ // self.sipcall.send({"message": body});
14675
15321
  }
14676
15322
  });
14677
15323
  break;
15324
+
15325
+ case 'accepted':
15326
+ self.playSucTimeOutIndex = setTimeout(function () {
15327
+ let _li = self.tagBox.parent();
15328
+
15329
+ _li.append('<div class="video-tip">网络环境较差,可能无法正常加载视频</div>');
15330
+ }, self.videoTipTimeOut * 1000);
15331
+ break;
14678
15332
  //呼叫失败
14679
15333
 
14680
15334
  case 'callfaild':
@@ -14693,7 +15347,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14693
15347
  case 'start_av_record':
14694
15348
  if (result && result.filename) {
14695
15349
  self.videoFileName = result.filename;
14696
- videoListener.dispatch('recordvideo', self);
15350
+ self.videoListener.dispatch('startRecordVideo', self);
15351
+ console.log('录像地址:' + result.filename);
15352
+ }
15353
+
15354
+ break;
15355
+
15356
+ case 'stop_av_record':
15357
+ if (result && result.filename) {
15358
+ self.videoFileName = result.filename;
15359
+ self.videoListener.dispatch('stopRecordVideo', self);
14697
15360
  console.log('录像地址:' + result.filename);
14698
15361
  }
14699
15362
 
@@ -14703,10 +15366,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14703
15366
  case 'ser_notify_resolution':
14704
15367
  if (result && result.resolution) {
14705
15368
  self.resolution = result.resolution;
14706
- videoListener.dispatch('notifyresolution', self);
15369
+ self.videoListener.dispatch('notifyresolution', self);
14707
15370
  console.log('接收notifyresolution:' + result.resolution); //promptAlarm('当前分辨率:' + result.resolution);
14708
15371
  }
14709
15372
 
15373
+ break;
15374
+
15375
+ case 'change_resolution':
15376
+ if (result) {
15377
+ self.videoListener.dispatch('notifyResolutionChange', self);
15378
+ }
15379
+
14710
15380
  break;
14711
15381
  //建立预呼叫响应
14712
15382
 
@@ -14743,9 +15413,38 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14743
15413
  break;
14744
15414
 
14745
15415
  case 'ser_stop_audio':
15416
+ self.tagBox.parent().find('.recv-audio-btn').attr("class", "unrecv-audio-btn");
14746
15417
  console.log('音频异常关闭!');
14747
15418
  break;
14748
15419
 
15420
+ case 'close_down_audio':
15421
+ self.tagBox.parent().find('.send-audio-btn').attr("class", "unsend-audio-btn");
15422
+ promptSuccess("通话时间到");
15423
+ console.log('通话时间到!');
15424
+ break;
15425
+
15426
+ case 'ser_notify_dispatch_close_ptop_poc':
15427
+ self.tagBox.parent().find('.send-audio-btn').attr("class", "unsend-audio-btn");
15428
+ console.log('调度通知点对点对讲关闭!');
15429
+ break;
15430
+
15431
+ case 'ser_close_ptop_poc':
15432
+ self.tagBox.parent().find('.send-audio-btn').attr("class", "unsend-audio-btn");
15433
+ console.log('点对点对讲关闭!');
15434
+ break;
15435
+
15436
+ case 'ser_open_ptop_poc':
15437
+ self.tagBox.parent().find('.unsend-audio-btn').attr("class", "send-audio-btn");
15438
+ console.log('点对点对讲打开!');
15439
+ break;
15440
+ // 视频关闭通知
15441
+
15442
+ case 'ser_close_video':
15443
+ console.log('视频框 ' + self.index + ' 视频已关闭');
15444
+ self.isClosing = false;
15445
+ self.videoListener.dispatch('notifyCloseVideo', self);
15446
+ break;
15447
+
14749
15448
  default:
14750
15449
  console.log('event:' + event);
14751
15450
  break;
@@ -14793,7 +15492,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14793
15492
 
14794
15493
  self.tagBox.bind("canplay play playing", function () {
14795
15494
  if (self.video) {
14796
- if (self.tagBox.is(':visible')) return;
15495
+ if (self.tagBox.is(':visible')) return; // 清除播放监测定时任务,清除内容
15496
+
15497
+ self.playSucTimeOutIndex > 0 && clearTimeout(self.playSucTimeOutIndex);
15498
+ self.tagBox.parent().find(".video-tip").remove();
14797
15499
  console.log('分屏=' + (self.index + 1) + ', ' + self.video + ' 播放成功');
14798
15500
  promptSuccess('分屏' + (self.index + 1) + ' 播放成功');
14799
15501
  self.tagBox.show(); //self.tagBox.parent().removeClass("loading").find(".stream-loading").remove();
@@ -14842,13 +15544,21 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14842
15544
  "message": body
14843
15545
  });
14844
15546
  this.video = video;
15547
+ this.isClosing = false;
14845
15548
  this.playing = true;
14846
15549
  this.packetsLostRate = '0.00%';
14847
15550
  this.packetsLostSum = 0;
14848
- this.packetsReceivedSum = 0; //loading
15551
+ this.packetsReceivedSum = 0;
15552
+ let numIndex = this.index + 1;
15553
+ let framesDecodedDom = document.getElementById("frame-decoded-" + numIndex);
15554
+ framesDecodedDom.style.display = 'none';
15555
+ this.framesDecodedLast = undefined;
15556
+ this.framesDecodedCount = 0; //loading
14849
15557
 
14850
15558
  let _li = this.tagBox.parent();
14851
15559
 
15560
+ clearResult(_li, this);
15561
+
14852
15562
  if (!_li.hasClass("loading")) {
14853
15563
  _li.addClass("loading").append('<div class="stream-loading">等待数据流传送...</div>');
14854
15564
  }
@@ -14861,8 +15571,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14861
15571
  if (!type) {
14862
15572
  this.isLockVideo = false;
14863
15573
  this.tagBox.parent().find('.lock-video-btn').attr("class", "unlock-video-btn");
14864
- } //let reqType = type ? type : "hangup";
15574
+ } //清除结果提示内容
15575
+
14865
15576
 
15577
+ clearResult(this.tagBox.parent(), this); //let reqType = type ? type : "hangup";
14866
15578
 
14867
15579
  if (!this.playing) return;
14868
15580
  let _hangup = {
@@ -14876,6 +15588,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14876
15588
  });
14877
15589
  this.sipcall.hangup();
14878
15590
  this.tagBox.hide();
15591
+ this.isClosing = true;
14879
15592
  this.playing = false;
14880
15593
  this.video = null;
14881
15594
  this.packetsLostRate = '0.00%';
@@ -14890,7 +15603,15 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14890
15603
 
14891
15604
  this.tagBox.parent().removeClass("loading").find(".stream-loading").remove(); //清除object-fit
14892
15605
 
14893
- this.tagBox.css('object-fit', '');
15606
+ this.tagBox.css('object-fit', ''); // 清除内容提示
15607
+
15608
+ this.playSucTimeOutIndex > 0 && clearTimeout(this.playSucTimeOutIndex);
15609
+ this.tagBox.parent().find(".video-tip").remove();
15610
+ var numIndex = Number(this.index) + 1;
15611
+ var framesDecodedDom = document.getElementById("frame-decoded-" + numIndex);
15612
+ framesDecodedDom.style.display = 'none';
15613
+ this.framesDecodedLast = undefined;
15614
+ this.framesDecodedCount = 0;
14894
15615
  },
14895
15616
 
14896
15617
  /**
@@ -14995,6 +15716,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14995
15716
 
14996
15717
  let _li = this.tagBox.parent();
14997
15718
 
15719
+ clearResult(_li, this);
15720
+
14998
15721
  if (!_li.hasClass("loading")) {
14999
15722
  _li.addClass("loading").append('<div class="stream-loading">等待数据流传送...</div>');
15000
15723
  }
@@ -15139,6 +15862,26 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
15139
15862
  "message": body
15140
15863
  });
15141
15864
  console.log("预呼叫操作=" + requestType + ", 对讲号码=" + pocNo + ",调度中心号码=" + centerTel);
15865
+ },
15866
+
15867
+ /**
15868
+ * 点对点对讲
15869
+ * requstType: open_ptop_poc(开启) close_poc_poc(关闭)
15870
+ * pocno
15871
+ */
15872
+ ptopPoc: function (requestType, pocNo) {
15873
+ let self = this;
15874
+ let body = {
15875
+ request: requestType,
15876
+ pocno: pocNo,
15877
+ playseq: self.index,
15878
+ pocmember: self.video,
15879
+ userToken: self.userToken
15880
+ };
15881
+ self.sipcall.send({
15882
+ "message": body
15883
+ });
15884
+ console.log("点对点对讲操作=" + requestType + ", 主叫号码=" + pocNo + ",被叫号码=" + self.video);
15142
15885
  }
15143
15886
  };
15144
15887
  return isIE() ? VideoOcx : VideoWebRtc;
@@ -28889,6 +29632,27 @@ let meet = {
28889
29632
  data: {}
28890
29633
  }
28891
29634
  },
29635
+
29636
+ /**
29637
+ * 设置主持人
29638
+ */
29639
+ setMeetChairmanNet: {
29640
+ url: '/dispatch-web/api/meet/setMeetChairman',
29641
+ method: 'POST',
29642
+ requestParam: {
29643
+ token: '',
29644
+ meetId: '',
29645
+ tel: ''
29646
+ },
29647
+ responseParam: {
29648
+ code: '',
29649
+ //返回结果状态码
29650
+ message: '',
29651
+ systemTime: '',
29652
+ //yyyy-MM-dd HH:mm:ss
29653
+ data: {}
29654
+ }
29655
+ },
28892
29656
  joinVideoMemberNet: {
28893
29657
  //成员加入会场(视频)
28894
29658
 
@@ -31491,6 +32255,20 @@ const meetOp = sip => {
31491
32255
  }, '', net.method);
31492
32256
  });
31493
32257
  },
32258
+ setChairman: function (param) {
32259
+ let net = meet_url.setMeetChairmanNet;
32260
+ return new Promise((resolve, reject) => {
32261
+ loadJson(server_ + net.url, { ...param
32262
+ }, function (ret) {
32263
+ if (ret.code == 0) {
32264
+ resolve(ret);
32265
+ } else {
32266
+ console.log("设置会场主持人失败", ret.code);
32267
+ reject(ret.code);
32268
+ }
32269
+ }, '', net.method);
32270
+ });
32271
+ },
31494
32272
  end: function (param) {
31495
32273
  let net = meet_url.endMeetNet;
31496
32274
  return new Promise((resolve, reject) => {