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.
@@ -12122,6 +12122,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
12122
12122
  }
12123
12123
 
12124
12124
  return e.returnValue;
12125
+ },
12126
+
12127
+ /**
12128
+ * 清空事件
12129
+ */
12130
+ removeAllListeners: function () {
12131
+ this._listeners = {};
12125
12132
  }
12126
12133
  };
12127
12134
  let videoListener = new Listener();
@@ -12762,21 +12769,21 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
12762
12769
  * 添加事件
12763
12770
  */
12764
12771
  addListener: function (type, handler, key) {
12765
- videoListener.addListener(type, handler, key);
12772
+ this.videoListener.addListener(type, handler, key);
12766
12773
  },
12767
12774
 
12768
12775
  /**
12769
12776
  * 删除事件
12770
12777
  */
12771
12778
  removeListener: function (type, handler) {
12772
- videoListener.removeListener(type, handler);
12779
+ this.videoListener.removeListener(type, handler);
12773
12780
  },
12774
12781
 
12775
12782
  /**
12776
12783
  * 派发事件
12777
12784
  */
12778
12785
  dispatch: function (e, options) {
12779
- videoListener.dispatch(e, options);
12786
+ this.videoListener.dispatch(e, options);
12780
12787
  },
12781
12788
 
12782
12789
  /**
@@ -13172,11 +13179,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13172
13179
  function VideoWebRtc($dom, opts) {
13173
13180
  let _self = this;
13174
13181
 
13182
+ _self.videoListener = new Listener();
13183
+
13175
13184
  if (!opts) {
13176
13185
  console.error('VideoWebRtc的参数opts不能为空');
13177
13186
  return;
13178
13187
  }
13179
13188
 
13189
+ _self.configOpt = opts && opts.configOpt || 3;
13180
13190
  hasMediaDevices(); //检测声卡设备为异步方法,耗时在几十毫秒左右,因此需要做延迟
13181
13191
  //默认检查次数为40 间隔为20ms
13182
13192
 
@@ -13186,11 +13196,59 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13186
13196
  clearInterval(index);
13187
13197
 
13188
13198
  _self._init($dom, opts);
13199
+
13200
+ let resizeObserver = new ResizeObserver(function (entries) {
13201
+ // console.log(entries)
13202
+ entries.forEach((item, index) => {
13203
+ let target = item.target;
13204
+ let videoLi = document.getElementById(me.selector).querySelectorAll('li');
13205
+
13206
+ _self.VIDEO_DATA.forEach((item, index) => {
13207
+ let tel = item.video;
13208
+
13209
+ if (!tel && item.id) {
13210
+ videoLi[index].querySelector('video').style = '';
13211
+ videoLi[index].querySelector('.rotate-btn').setAttribute('rotate-index', 0);
13212
+ } else {
13213
+ let rotateIndex = $(videoLi[index]).find('button[name=rotateVideo]').attr('rotate-index');
13214
+ setTimeout(() => {
13215
+ _self.videoRotateSize(videoLi[index], rotateIndex);
13216
+ }, 200);
13217
+ }
13218
+ });
13219
+ });
13220
+ }); // 监听dom
13221
+
13222
+ resizeObserver.observe(document.querySelector(_self.selector));
13189
13223
  } else {
13190
13224
  if (window.checkAudioDevicesStatus) {
13191
13225
  clearInterval(index);
13192
13226
 
13193
13227
  _self._init($dom, opts);
13228
+
13229
+ let resizeObserver = new ResizeObserver(function (entries) {
13230
+ // console.log(entries)
13231
+ entries.forEach((item, index) => {
13232
+ let target = item.target;
13233
+ let videoLi = document.getElementById(me.selector).querySelectorAll('li');
13234
+
13235
+ _self.VIDEO_DATA.forEach((item, index) => {
13236
+ let tel = item.video;
13237
+
13238
+ if (!tel && item.id) {
13239
+ videoLi[index].querySelector('video').style = '';
13240
+ videoLi[index].querySelector('.rotate-btn').setAttribute('rotate-index', 0);
13241
+ } else {
13242
+ let rotateIndex = $(videoLi[index]).find('button[name=rotateVideo]').attr('rotate-index');
13243
+ setTimeout(() => {
13244
+ _self.videoRotateSize(videoLi[index], rotateIndex);
13245
+ }, 200);
13246
+ }
13247
+ });
13248
+ });
13249
+ }); // 监听dom
13250
+
13251
+ resizeObserver.observe(document.querySelector(_self.selector));
13194
13252
  }
13195
13253
  }
13196
13254
 
@@ -13217,6 +13275,13 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13217
13275
  // console.info('该视频正在播放');
13218
13276
  // return false;
13219
13277
  // }
13278
+ // 启用播放队列时,当前位置正在关闭上一个视频,则加入播放队列
13279
+
13280
+ if (me.waitPlayQueueSwitch && me.VIDEO_DATA[index].isClosing) {
13281
+ me._addWaitingVideo(index, video, id, opts);
13282
+
13283
+ return;
13284
+ }
13220
13285
 
13221
13286
  console.log("play >>> " + "video=" + video + "; id=" + id + "; index=" + index);
13222
13287
  me.dispatch('beforeplay', {
@@ -13315,7 +13380,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13315
13380
  */
13316
13381
  playInChoice: function (video, id, opts) {
13317
13382
  let me = this;
13318
- let selView = $('[video-flag="' + me._opts.windowsBeginIndex + '"]>li.sel');
13383
+ let selView = $(me.selector + ' li.sel');
13319
13384
 
13320
13385
  if (selView.length) {
13321
13386
  if (me.VIDEO_DATA[selView.index()].playing) {
@@ -13372,6 +13437,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13372
13437
  this.VIDEO_DATA[index].close();
13373
13438
 
13374
13439
  if (!isSave) {
13440
+ this.VIDEO_DATA[index].closeType = 'close';
13375
13441
  this.dispatch('afterclose', this.VIDEO_DATA[index]);
13376
13442
  }
13377
13443
  },
@@ -13398,6 +13464,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13398
13464
  me.close(videoData[i].index);
13399
13465
 
13400
13466
  if (!isSave) {
13467
+ videoData[i].closeType = 'close';
13401
13468
  me.dispatch('afterclose', videoData[i]);
13402
13469
  }
13403
13470
  }
@@ -13408,13 +13475,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13408
13475
  * 关闭所有视频
13409
13476
  */
13410
13477
  closeAll: function (isSave) {
13411
- let me = this;
13478
+ let me = this; // 清除所有等待播放队列
13479
+
13480
+ me._removeAllWaitingVideo();
13481
+
13412
13482
  let openVideos = [];
13413
13483
 
13414
13484
  for (let i = me._opts.windowsBeginIndex; i < me._opts.windowsBeginIndex + me._opts.windowsNum; i++) {
13415
- if (me.VIDEO_DATA[i].playing) {
13416
- me.close(i, isSave);
13417
- }
13485
+ // if(me.VIDEO_DATA[i].playing){
13486
+ // me.close(i, isSave)
13487
+ // }
13488
+ me.close(i, isSave);
13418
13489
  } // if(!openVideos.length) return;
13419
13490
  //
13420
13491
  // //适当延时进行关闭
@@ -13454,9 +13525,9 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13454
13525
  me.setChoiceWindow(me._getMinIndexFreeWindow());
13455
13526
  }
13456
13527
 
13457
- $('[video-flag="' + me._opts.windowsBeginIndex + '"]').removeClass("mode-" + me._opts.windows).addClass("mode-" + num);
13528
+ $(me.selector + ' .video-main').removeClass("mode-" + me._opts.windows).addClass("mode-" + num);
13458
13529
 
13459
- let _li = $('[video-flag="' + me._opts.windowsBeginIndex + '"]>li').hide();
13530
+ let _li = $(me.selector + ' li').hide();
13460
13531
 
13461
13532
  me._opts.windows = num;
13462
13533
 
@@ -13470,7 +13541,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13470
13541
  flag: me._opts.flag
13471
13542
  }); //设置旋转了的视频样式
13472
13543
 
13473
- let videoLi = document.getElementById('videoRef').querySelectorAll('li');
13544
+ let videoLi = document.getElementById(me.selector).querySelectorAll('li');
13474
13545
  me.VIDEO_DATA.forEach((item, index) => {
13475
13546
  let tel = item.video;
13476
13547
 
@@ -13481,13 +13552,12 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13481
13552
  }); //设置旋转视频的样式
13482
13553
 
13483
13554
  for (let k = 0; k < _li.length; k++) {
13484
- let rotateIndex = _li.eq(k).find('button[name=rotateVideo]').attr('rotate-index');
13555
+ let rotateIndex = _li.eq(k).find('button[name=rotateVideo]').attr('rotate-index'); // if(rotateIndex != 0 && rotateIndex != 2){
13485
13556
 
13486
- if (rotateIndex != 0 && rotateIndex != 2) {
13487
- setTimeout(() => {
13488
- me.videoRotateSize(_li.eq(k)[0], rotateIndex);
13489
- }, 200);
13490
- }
13557
+
13558
+ setTimeout(() => {
13559
+ me.videoRotateSize(_li.eq(k)[0], rotateIndex);
13560
+ }, 200); // }
13491
13561
  }
13492
13562
  },
13493
13563
 
@@ -13516,7 +13586,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13516
13586
  me.saveList();
13517
13587
  this._polltimer = new PollTimer(function (firstRun) {
13518
13588
  me.closeAll();
13519
- wait(500).then(function () {
13589
+
13590
+ if (firstRun) {
13520
13591
  for (let i = 0; i < windowNum; i++) {
13521
13592
  if (nowNum == maxNum) {
13522
13593
  nowNum = 0;
@@ -13530,10 +13601,23 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13530
13601
  nowNum++;
13531
13602
  }
13532
13603
 
13533
- if (firstRun) {
13534
- me.dispatch('startpoll', array);
13535
- }
13536
- });
13604
+ me.dispatch('startpoll', array);
13605
+ } else {
13606
+ wait(1500).then(function () {
13607
+ for (let i = 0; i < windowNum; i++) {
13608
+ if (nowNum == maxNum) {
13609
+ nowNum = 0;
13610
+
13611
+ if (maxNum < windowNum) {
13612
+ break;
13613
+ }
13614
+ }
13615
+
13616
+ me.playByOrder(array[nowNum].video, array[nowNum].id, array[nowNum].opts);
13617
+ nowNum++;
13618
+ }
13619
+ });
13620
+ }
13537
13621
  }, time);
13538
13622
  },
13539
13623
 
@@ -13656,10 +13740,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13656
13740
  */
13657
13741
  getInChoiceVideo: function () {
13658
13742
  let me = this;
13659
- let selView = $('[video-flag="' + me._opts.windowsBeginIndex + '"]>li.sel');
13743
+ let selView = $(me.selector + ' li.sel');
13660
13744
 
13661
- if (selView.length && me.VIDEO_DATA[selView.index()].video) {
13662
- return me.VIDEO_DATA[selView.index()];
13745
+ if (selView.length && me.VIDEO_DATA[selView.attr("index")].video) {
13746
+ return me.VIDEO_DATA[selView.attr("index")];
13663
13747
  }
13664
13748
 
13665
13749
  return undefined;
@@ -13695,10 +13779,23 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13695
13779
 
13696
13780
  let canvasObj = document.getElementById('myCanvas');
13697
13781
  let videoObj = dataObj.tagBox.get(0);
13698
- canvasObj.width = dataObj.tagBox.parent().width();
13699
- canvasObj.height = dataObj.tagBox.parent().height();
13782
+
13783
+ if (videoObj == undefined) {
13784
+ return;
13785
+ } // 取流中 取视频框尺寸
13786
+ // 播放中 取视频画面尺寸
13787
+
13788
+
13789
+ if (dataObj.tagBox.parent().find(".stream-loading").length != 0) {
13790
+ canvasObj.width = dataObj.tagBox.width();
13791
+ canvasObj.height = dataObj.tagBox.height();
13792
+ } else {
13793
+ canvasObj.width = videoObj.videoWidth;
13794
+ canvasObj.height = videoObj.videoHeight;
13795
+ }
13796
+
13700
13797
  let ctx = canvasObj.getContext("2d");
13701
- ctx.drawImage(videoObj, 0, 0, dataObj.tagBox.parent().width(), dataObj.tagBox.parent().height());
13798
+ ctx.drawImage(videoObj, 0, 0, videoObj.videoWidth, videoObj.videoHeight);
13702
13799
  let dataUrl = canvasObj.toDataURL('image/jpeg');
13703
13800
  callback ? callback(dataUrl) : null;
13704
13801
  },
@@ -13745,8 +13842,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13745
13842
 
13746
13843
  if (index < 0) {
13747
13844
  console.error('窗口编号获取失败!');
13748
- }
13845
+ } //保存对讲号码
13846
+
13749
13847
 
13848
+ window.pocNo = pocNo;
13750
13849
  return me.VIDEO_DATA[index].pocCall("open_poccall", pocNo, centerTel);
13751
13850
  },
13752
13851
 
@@ -13770,6 +13869,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13770
13869
  }
13771
13870
 
13772
13871
  me.VIDEO_DATA[index].stream = null;
13872
+ window.pocNo = null;
13773
13873
  return me.VIDEO_DATA[index].pocCall("close_poccall", pocNo, centerTel);
13774
13874
  },
13775
13875
 
@@ -13804,21 +13904,28 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13804
13904
  * 添加事件
13805
13905
  */
13806
13906
  addListener: function (type, handler, key) {
13807
- videoListener.addListener(type, handler, key);
13907
+ this.videoListener.addListener(type, handler, key);
13808
13908
  },
13809
13909
 
13810
13910
  /**
13811
13911
  * 删除事件
13812
13912
  */
13813
13913
  removeListener: function (type, handler) {
13814
- videoListener.removeListener(type, handler);
13914
+ this.videoListener.removeListener(type, handler);
13815
13915
  },
13816
13916
 
13817
13917
  /**
13818
13918
  * 派发事件
13819
13919
  */
13820
13920
  dispatch: function (e, options) {
13821
- videoListener.dispatch(e, options);
13921
+ this.videoListener.dispatch(e, options);
13922
+ },
13923
+
13924
+ /**
13925
+ * 清空事件
13926
+ */
13927
+ removeAllListeners: function () {
13928
+ this.videoListener.removeAllListeners();
13822
13929
  },
13823
13930
 
13824
13931
  /**
@@ -13829,7 +13936,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13829
13936
  index = index || me._opts.windowsBeginIndex;
13830
13937
 
13831
13938
  for (; index < me._opts.windowsBeginIndex + me._opts.windows; index++) {
13832
- if (!me.VIDEO_DATA[index].playing) {
13939
+ if (!me.VIDEO_DATA[index].playing && !me.VIDEO_DATA[index].isWaiting) {
13833
13940
  return index;
13834
13941
  }
13835
13942
  }
@@ -13842,7 +13949,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13842
13949
  */
13843
13950
  _getChoiceWindow: function () {
13844
13951
  let me = this;
13845
- let selView = $('[video-flag="' + me._opts.windowsBeginIndex + '"]>li.sel');
13952
+ let selView = $(me.selector + ' li.sel');
13846
13953
 
13847
13954
  if (selView.length) {
13848
13955
  return selView.index();
@@ -13875,13 +13982,40 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13875
13982
  _clickWindow: function () {
13876
13983
  let me = this; //视频窗口选中
13877
13984
 
13878
- $('[video-flag="' + me._opts.windowsBeginIndex + '"]>li').click(function () {
13879
- $('[video-flag="' + me._opts.windowsBeginIndex + '"]>li').removeClass("sel");
13985
+ $(me.selector + ' li').click(function () {
13986
+ $(me.selector + ' li').removeClass("sel");
13880
13987
  $(this).addClass("sel"); //如果视频正在播放则分发点击消息
13881
13988
 
13882
13989
  if (me.getInChoiceVideo()) {
13883
13990
  me.dispatch('click', me.getInChoiceVideo());
13884
13991
  }
13992
+ }); // 设置视频窗可拖拽
13993
+
13994
+ let src = null;
13995
+ $(me.selector + ' li').bind("dragstart", function (ev) {
13996
+ src = $(this);
13997
+ });
13998
+ $(me.selector + ' li').bind("dragover", function (ev) {
13999
+ ev.preventDefault();
14000
+ });
14001
+ $(me.selector + ' li').bind("drop", function (ev) {
14002
+ ev.preventDefault();
14003
+
14004
+ if (src.prop("outerHTML") === $(this).prop("outerHTML")) {
14005
+ return;
14006
+ }
14007
+
14008
+ let target = $(this);
14009
+ let srcIndex = src.index();
14010
+ let targetIndex = target.index();
14011
+
14012
+ if (srcIndex > targetIndex) {
14013
+ src.insertBefore(target);
14014
+ target.insertAfter($(me.selector + ' .video-main li.screen').eq(srcIndex));
14015
+ } else {
14016
+ src.insertAfter(target);
14017
+ target.insertBefore($(me.selector + ' .video-main li.screen').eq(srcIndex));
14018
+ }
13885
14019
  });
13886
14020
  },
13887
14021
 
@@ -13912,7 +14046,15 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13912
14046
  conf: {},
13913
14047
  pollInterval: 10,
13914
14048
  windowsNum: 16,
13915
- isVideoTag: true //true生成video标签 false生产audio标签 默认true
14049
+ isVideoTag: true,
14050
+ //true生成video标签 false生产audio标签 默认true
14051
+ showVideoInfo: 1,
14052
+ //显示分辨率、码率等信息,1-显示左下角 2-显示左上角,为0时控制_showVideoInfo函数处理,默认1
14053
+ waitPlayQueueSwitch: false,
14054
+ //播放队列开关,默认false
14055
+ defaultBusinessType: 0,
14056
+ // 配置的默认业务类型 0:调度主线 1:勤指
14057
+ videoTipTimeOut: 5 // 超时无首屏检测时间
13916
14058
 
13917
14059
  };
13918
14060
  $.extend(me._opts, opts);
@@ -13939,24 +14081,33 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
13939
14081
  } //获取起始的窗口位置
13940
14082
 
13941
14083
 
13942
- me._opts.windowsBeginIndex = windowsSum; //窗口总数
14084
+ me._opts.windowsBeginIndex = 0; // 对讲号码初始化
14085
+
14086
+ window.pocNo = 0; // 播放队列开关 默认打开
14087
+
14088
+ me.waitPlayQueueSwitch = opts.waitPlayQueueSwitch == undefined ? false : opts.waitPlayQueueSwitch; //是否提示
13943
14089
 
13944
- windowsSum += me._opts.windowsNum; //是否提示
14090
+ me._opts.showPrompt === false && (showPrompt = false); // 勤指业务下 设备检测
13945
14091
 
13946
- me._opts.showPrompt === false && (showPrompt = false); //初始化界面
14092
+ me._opts.defaultBusinessType == 1 && me._checkDevices(); //初始化界面
13947
14093
 
13948
- me._opts.isVideoTag ? me._initVideoView($dom) : me._initAudioView($dom); //初始化Janus
14094
+ me._opts.isVideoTag ? me._initVideoView($dom, me._opts.showVideoInfo) : me._initAudioView($dom); //初始化Janus
13949
14095
 
13950
14096
  me._initJanus(); //初始化按钮点击事件
13951
14097
 
13952
14098
 
13953
- me._initBtnEvent(); //设置鼠标点击选中窗口
14099
+ me._initBtnEvent(); // 初始化事件监听
13954
14100
 
13955
14101
 
13956
- me._clickWindow(); //显示视频信息:名称、分辨率、码率、丢包率
14102
+ me._initEventListen(); //设置鼠标点击选中窗口
13957
14103
 
13958
14104
 
13959
- me._showVideoInfo(); //双击某个视频全屏
14105
+ me._clickWindow();
14106
+
14107
+ if (me._opts.showVideoInfo != 0) {
14108
+ //显示视频信息:名称、分辨率、码率、丢包率
14109
+ me._showVideoInfo();
14110
+ } //双击某个视频全屏
13960
14111
 
13961
14112
 
13962
14113
  me._dbClickFullScreen();
@@ -14070,35 +14221,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14070
14221
  * 初始化按钮点击事件
14071
14222
  */
14072
14223
  _initBtnEvent: function () {
14073
- let me = this; // 设置视频窗可拖拽
14074
-
14075
- var src = null;
14076
- $(me.selector + ' li').bind("dragstart", function (ev) {
14077
- src = $(this);
14078
- });
14079
- $(me.selector + ' li').bind("dragover", function (ev) {
14080
- ev.preventDefault();
14081
- });
14082
- $(me.selector + ' li').bind("drop", function (ev) {
14083
- ev.preventDefault();
14084
-
14085
- if (src.prop("outerHTML") === $(this).prop("outerHTML")) {
14086
- return;
14087
- }
14088
-
14089
- var target = $(this);
14090
- var srcIndex = src.index();
14091
- var targetIndex = target.index();
14092
-
14093
- if (srcIndex > targetIndex) {
14094
- src.insertBefore(target);
14095
- target.insertAfter($(me.selector + ' .video-main li.screen').eq(srcIndex));
14096
- } else {
14097
- src.insertAfter(target);
14098
- target.insertBefore($(me.selector + ' .video-main li.screen').eq(srcIndex));
14099
- }
14100
- });
14101
- let videoFlagObj = $('[video-flag="' + me._opts.windowsBeginIndex + '"]'); //锁定视频事件
14224
+ let me = this;
14225
+ let videoFlagObj = $(me.selector + ' .video-main'); //锁定视频事件
14102
14226
 
14103
14227
  videoFlagObj.find("button[name='lockVideo']").click(function () {
14104
14228
  let index = Number($(this).parent().parent().attr("index"));
@@ -14114,7 +14238,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14114
14238
  } else {
14115
14239
  me.VIDEO_DATA[index].isLockVideo = true;
14116
14240
  $(this).attr('class', 'lock-video-btn');
14117
- }
14241
+ } //jquery方式阻止默认事件 & 冒泡事件
14242
+
14243
+
14244
+ return false;
14118
14245
  });
14119
14246
  videoFlagObj.find('button[name=rotateVideo]').click(function () {
14120
14247
  let rotateIndex = Number($(this).attr("rotate-index"));
@@ -14122,13 +14249,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14122
14249
  rotateIndex %= 4;
14123
14250
  $(this).attr("rotate-index", rotateIndex);
14124
14251
  let li = $(this).parent().parent()[0];
14125
- me.videoRotateSize(li, rotateIndex);
14252
+ me.videoRotateSize(li, rotateIndex); //jquery方式阻止默认事件 & 冒泡事件
14253
+
14254
+ return false;
14126
14255
  }); //接收音频事件
14127
14256
 
14128
14257
  videoFlagObj.find("button[name='recvAudio']").click(function () {
14129
14258
  let _self = this;
14130
14259
 
14131
- let index = Number($(this).parent().parent().attr("index"));
14260
+ let index = Number($(this).parent().parent().attr("index")); // 优先当前窗口参数设置的业务类型 其次配置的默认业务类型
14261
+
14262
+ let businessType = me.VIDEO_DATA[index].opts.businessType == undefined ? me._opts.defaultBusinessType : me.VIDEO_DATA[index].opts.businessType;
14132
14263
 
14133
14264
  if (!me.VIDEO_DATA[index].playing) {
14134
14265
  promptAlarm('请选择播放的视频源!');
@@ -14139,65 +14270,112 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14139
14270
  //发送停止播放音频的请求
14140
14271
  me.VIDEO_DATA[index].operateAudio("stop_audio");
14141
14272
  $(this).attr('class', 'unrecv-audio-btn');
14142
- me.VIDEO_DATA[index].tagBox.muted = false;
14273
+ me.VIDEO_DATA[index].tagBox.prop("muted", true);
14143
14274
  } else {
14144
- //发送前先关闭其它音频通道(包括接收和发送音频)
14145
- let lis = $($(_self).parent().parent().parent()).children();
14275
+ if (businessType == 0) {
14276
+ //发送前先关闭其它音频通道(包括接收和发送音频)
14277
+ let lis = $($(_self).parent().parent().parent()).children();
14146
14278
 
14147
- for (let i = 0; i < lis.length; i++) {
14148
- let btnIndex = Number($(lis[i]).attr("index"));
14279
+ for (let i = 0; i < lis.length; i++) {
14280
+ let btnIndex = Number($(lis[i]).attr("index"));
14149
14281
 
14150
- if (index == btnIndex) {
14151
- continue;
14152
- }
14282
+ if (index == btnIndex) {
14283
+ continue;
14284
+ }
14153
14285
 
14154
- let recvBtn = $($(lis[i]).find("button[name='recvAudio']")[0]);
14155
- let sendBtn = $($(lis[i]).find("button[name='sendAudio']")[0]);
14286
+ let recvBtn = $($(lis[i]).find("button[name='recvAudio']")[0]);
14287
+ let sendBtn = $($(lis[i]).find("button[name='sendAudio']")[0]);
14156
14288
 
14157
- if (recvBtn.attr("class") == 'recv-audio-btn') {
14158
- if (me.VIDEO_DATA[btnIndex].playing) {
14159
- recvBtn.click();
14289
+ if (recvBtn.attr("class") == 'recv-audio-btn') {
14290
+ if (me.VIDEO_DATA[btnIndex].playing) {
14291
+ recvBtn.click();
14292
+ }
14160
14293
  }
14161
- }
14162
14294
 
14163
- if (sendBtn.attr("class") == 'send-audio-btn') {
14164
- if (me.VIDEO_DATA[btnIndex].playing) {
14165
- sendBtn.click();
14295
+ if (sendBtn.attr("class") == 'send-audio-btn') {
14296
+ if (me.VIDEO_DATA[btnIndex].playing) {
14297
+ sendBtn.click();
14298
+ }
14166
14299
  }
14167
- }
14168
- } //发送播放音频的请求
14300
+ } //发送播放音频的请求
14169
14301
 
14170
14302
 
14171
- $(_self).attr('class', 'recv-audio-btn');
14172
- setTimeout(function () {
14303
+ $(_self).attr('class', 'recv-audio-btn');
14304
+ setTimeout(function () {
14305
+ if (!me.VIDEO_DATA[index].isClosing) {
14306
+ me.VIDEO_DATA[index].operateAudio("recv_audio");
14307
+ me.VIDEO_DATA[index].tagBox.prop("muted", false);
14308
+ }
14309
+ }, 1000);
14310
+ } else if (businessType == 1) {
14311
+ // poc新模式支持回传多个音频,因此不关闭
14312
+ //发送播放音频的请求
14313
+ $(_self).attr('class', 'recv-audio-btn');
14173
14314
  me.VIDEO_DATA[index].operateAudio("recv_audio");
14174
- me.VIDEO_DATA[index].tagBox.muted = true;
14175
- }, 1000);
14315
+ me.VIDEO_DATA[index].tagBox.prop("muted", false);
14316
+ }
14176
14317
  }
14177
14318
  }); //发送音频事件
14178
14319
 
14179
14320
  videoFlagObj.find("button[name='sendAudio']").click(function () {
14180
- let index = Number($(this).parent().parent().attr("index"));
14321
+ let index = Number($(this).parent().parent().attr("index")); // 优先当前窗口参数设置的业务类型 其次配置的默认业务类型 最后默认调度业务
14322
+
14323
+ let businessType = me.VIDEO_DATA[index].opts.businessType == undefined ? me._opts.defaultBusinessType : me.VIDEO_DATA[index].opts.businessType;
14181
14324
 
14182
14325
  if (!me.VIDEO_DATA[index].playing) {
14183
14326
  promptAlarm('请选择播放的视频源!');
14184
14327
  return;
14185
14328
  }
14186
14329
 
14187
- if ($(this).attr('class') == 'send-audio-btn') {
14188
- me.VIDEO_DATA[index].operateAudio("unsend_audio");
14189
- $(this).attr('class', 'unsend-audio-btn');
14190
- me.VIDEO_DATA[index].stream.getAudioTracks()[0].enabled = false;
14191
- } else {
14192
- me.VIDEO_DATA[index].operateAudio("send_audio");
14193
- $(this).attr('class', 'send-audio-btn');
14194
- me.VIDEO_DATA[index].stream.getAudioTracks()[0].enabled = true;
14195
- }
14330
+ if (businessType == 0) {
14331
+ // 主线业务
14332
+ if ($(this).attr('class') == 'send-audio-btn') {
14333
+ me.VIDEO_DATA[index].operateAudio("unsend_audio");
14334
+ $(this).attr('class', 'unsend-audio-btn');
14335
+ me.VIDEO_DATA[index].stream.getAudioTracks()[0].enabled = false;
14336
+ } else {
14337
+ me.VIDEO_DATA[index].operateAudio("send_audio");
14338
+ $(this).attr('class', 'send-audio-btn');
14339
+ me.VIDEO_DATA[index].stream.getAudioTracks()[0].enabled = true;
14340
+ }
14341
+ } else if (businessType == 1) {
14342
+ // 勤指业务
14343
+ if ($(this).attr('class') == 'send-audio-btn') {
14344
+ $(this).attr('class', 'unsend-audio-btn'); //关闭点对点对讲
14345
+
14346
+ me.VIDEO_DATA[index].ptopPoc("close_ptop_poc", window.pocNo);
14347
+ } else {
14348
+ $(this).attr('class', 'send-audio-btn'); //发起点对点对讲
14349
+
14350
+ me.VIDEO_DATA[index].ptopPoc("open_ptop_poc", window.pocNo);
14351
+ }
14352
+ } //jquery方式阻止默认事件 & 冒泡事件
14353
+
14354
+
14355
+ return false;
14196
14356
  }); //关闭视频事件
14197
14357
 
14198
14358
  videoFlagObj.find("button[name='closeVideo']").click(function () {
14199
14359
  let index = Number($(this).parent().parent().attr("index"));
14200
- me.close(index);
14360
+ me.close(index); // //jquery方式阻止默认事件 & 冒泡事件
14361
+ // return false;
14362
+ });
14363
+ },
14364
+
14365
+ /**
14366
+ * 初始化事件监听
14367
+ */
14368
+ _initEventListen: function () {
14369
+ let _self = this; // 打开视频 {index, video, id, opts} index(视频窗口编号,从0开始) video(视频设备id,即devId) id(标识,空的话使用设备id) opts(其他参数)
14370
+
14371
+
14372
+ _self.addListener('openVideo', function (e) {
14373
+ _self.play(e.index, e.video, e.id, e.opts);
14374
+ }); // janus通知后台已关闭视频
14375
+
14376
+
14377
+ _self.addListener('notifyCloseVideo', function (e) {
14378
+ _self._notifyWaitingVideo(e.index);
14201
14379
  });
14202
14380
  },
14203
14381
 
@@ -14206,7 +14384,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14206
14384
  */
14207
14385
  _dbClickFullScreen: function () {
14208
14386
  let me = this;
14209
- $('[video-flag="' + me._opts.windowsBeginIndex + '"]').find('.video-box').on("dblclick", function () {
14387
+ $(me.selector + ' .video-main').find('.video-box').on("dblclick", function () {
14210
14388
  me._fullScreenEvent(this);
14211
14389
  });
14212
14390
  },
@@ -14241,10 +14419,20 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14241
14419
  let me = this;
14242
14420
 
14243
14421
  function clock() {
14422
+ if (!me.VIDEO_DATA || !me.VIDEO_DATA.length) return;
14423
+
14244
14424
  for (let i = 0; i < me.VIDEO_DATA.length; i++) {
14245
14425
  if (me.VIDEO_DATA[i].playing) {
14246
- let number = Number(i) + Number(1);
14247
- let videoObj = document.getElementById('video-' + number);
14426
+ let number = Number(i) + Number(1); //获取视频video标签
14427
+
14428
+ let $videoList = $(me.selector + " .video-main #video-" + number);
14429
+
14430
+ if (!$videoList.length) {
14431
+ console.error("can not find dom by id [video-" + number + "]");
14432
+ continue;
14433
+ }
14434
+
14435
+ let videoObj = $videoList[0];
14248
14436
  if (!videoObj) continue;
14249
14437
  let width = videoObj.videoWidth;
14250
14438
  let height = videoObj.videoHeight; //码率
@@ -14259,6 +14447,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14259
14447
 
14260
14448
  me._setPacketsLostRate(i, config, me);
14261
14449
 
14450
+ me._setFrameDecoded(i, config, me);
14451
+
14262
14452
  let resolution = width + "×" + height;
14263
14453
 
14264
14454
  switch (height + '') {
@@ -14280,11 +14470,26 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14280
14470
 
14281
14471
  default:
14282
14472
  break;
14473
+ } //获取文案显示dom元素
14474
+
14475
+
14476
+ let $videoInfoList = $(me.selector + " .video-main #info-" + number);
14477
+
14478
+ if (!$videoInfoList.length) {
14479
+ console.error("can not find dom by id [info-" + number + "]");
14480
+ continue;
14283
14481
  }
14284
14482
 
14285
- let videoInfoObj = document.getElementById('info-' + number);
14483
+ let videoInfoObj = $videoInfoList[0];
14286
14484
  let videoName = me.VIDEO_DATA[i].opts && me.VIDEO_DATA[i].opts.name ? me.VIDEO_DATA[i].opts.name : me.VIDEO_DATA[i].video;
14287
- videoInfoObj.innerHTML = videoName + '&nbsp;&nbsp;' + resolution + '<br>丢包率:' + me.VIDEO_DATA[i].packetsLostRate + '&nbsp;&nbsp;' + bitrate.replace("kbits/sec", "kbps");
14485
+ videoInfoObj.innerHTML = videoName + '&nbsp;&nbsp;' + resolution + '<br>丢包率:' + me.VIDEO_DATA[i].packetsLostRate + '&nbsp;&nbsp;' + bitrate.replace("kbits/sec", "kbps"); //根据视频框大小自动计算 显示文案的文字大小
14486
+
14487
+ let fontHeightSize = $(me.selector + " .video-main #video-" + number).height() / 15;
14488
+ let fontWidthSize = $(me.selector + " .video-main #video-" + number).width() / 18; //长和宽 除以 15, 取小的值做文字大小样式
14489
+
14490
+ let fontSize = fontHeightSize < fontWidthSize ? fontHeightSize : fontWidthSize;
14491
+ fontSize = !fontSize || fontSize > 20 ? 20 : fontSize;
14492
+ $("#info-" + number).css("font-size", fontSize + "px");
14288
14493
  }
14289
14494
  }
14290
14495
  } //已存在则清除
@@ -14347,17 +14552,175 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14347
14552
  }
14348
14553
  },
14349
14554
 
14555
+ /**
14556
+ * 设置当前网络信号提示
14557
+ * @param index 当前打开视频的索引
14558
+ * @param config
14559
+ * @param me
14560
+ * @private
14561
+ */
14562
+ _setFrameDecoded: function (index, config, me) {
14563
+ if (config.pc !== null && typeof config.pc !== 'undefined' && config.pc.getStats) {
14564
+ config.pc.getStats().then(function (stats) {
14565
+ stats.forEach(function (res) {
14566
+ if (res) {
14567
+ let inStats = false; // Check if these are statistics on incoming media
14568
+
14569
+ if ((res.mediaType === 'video' || res.id.toLowerCase().indexOf('video') > -1) && res.type === 'inbound-rtp' && res.id.indexOf('rtcp') < 0) {
14570
+ // New stats
14571
+ inStats = true;
14572
+ } else if (res.type === 'ssrc' && res.bytesReceived && (res.googCodecName === 'VP8' || res.googCodecName === '')) {
14573
+ // Older Chromer versions
14574
+ inStats = true;
14575
+ } // Parse stats now
14576
+
14577
+
14578
+ if (inStats) {
14579
+ if (res.hasOwnProperty('framesDecoded')) {
14580
+ if (res.framesDecoded <= 1) return;
14581
+
14582
+ if (typeof me.VIDEO_DATA[index].framesDecodedCount === 'undefined') {
14583
+ me.VIDEO_DATA[index].framesDecodedCount = 0;
14584
+ }
14585
+
14586
+ if (typeof me.VIDEO_DATA[index].framesDecodedLast === 'undefined') {
14587
+ me.VIDEO_DATA[index].framesDecodedLast = res.framesDecoded;
14588
+ }
14589
+
14590
+ if (res.framesDecoded > me.VIDEO_DATA[index].framesDecodedLast) {
14591
+ if (typeof me.VIDEO_DATA[index].tipDom !== 'undefined' && me.VIDEO_DATA[index].tipDom.style.display === 'block') {
14592
+ me.VIDEO_DATA[index].tipDom.style.display = 'none';
14593
+ }
14594
+ }
14595
+
14596
+ me.VIDEO_DATA[index].framesDecodedCount++; // 定时检测
14597
+
14598
+ if (me.VIDEO_DATA[index].framesDecodedCount === me.configOpt) {
14599
+ if (res.framesDecoded - me.VIDEO_DATA[index].framesDecodedLast === 0) {
14600
+ // 卡顿
14601
+ if (typeof me.VIDEO_DATA[index].tipDom === 'undefined') {
14602
+ var numIndex = index + 1;
14603
+ me.VIDEO_DATA[index].tipDom = document.getElementById('frame-decoded-' + numIndex);
14604
+ }
14605
+
14606
+ me.VIDEO_DATA[index].tipDom.style.display = 'block';
14607
+ }
14608
+
14609
+ me.VIDEO_DATA[index].framesDecodedCount = 0;
14610
+ me.VIDEO_DATA[index].framesDecodedLast = res.framesDecoded;
14611
+ } else {
14612
+ me.VIDEO_DATA[index].framesDecodedLast = res.framesDecoded;
14613
+ }
14614
+ }
14615
+ }
14616
+ }
14617
+ });
14618
+ });
14619
+ }
14620
+ },
14621
+
14622
+ /**
14623
+ * 设备可用性检查(扬声器、麦克风、分辨率、浏览器类型)
14624
+ * 1. 未检测(status == undefined)询问进入检测界面
14625
+ * 2. 检测完成按相应结果给予相应提示
14626
+ * 3. 拒绝检测按所有检测通过处理
14627
+ * 4. 程序自行检测,并将是否加载声卡结果放入window对象
14628
+ * @private
14629
+ */
14630
+ _checkDevices: function () {
14631
+ let me = this;
14632
+ let tipCountKey = "DEVICES_CHECK_TIP_COUNT";
14633
+ let statusKey = "DEVICES_CHECK_STATUS";
14634
+ let checkCompleted = "completed";
14635
+ let checkRejected = "rejected";
14636
+ let microResultKey = "MICRO_RESULT";
14637
+ let speakerResultKey = "SPEAKER_RESULT";
14638
+ let screenResultKey = "SCREEN_RESULT";
14639
+ let resultPass = "pass";
14640
+ let resultNotPass = "not pass";
14641
+ let tipCount = sessionStorage.getItem(tipCountKey);
14642
+ let status = localStorage.getItem(statusKey);
14643
+
14644
+ if ((tipCount == undefined || tipCount == "0") && status == undefined) {
14645
+ sessionStorage.setItem(tipCountKey, "1"); //弹窗讯问是否进入检测界面
14646
+
14647
+ if (confirm("您还没有检测硬件设备,是否先进行检测?")) {
14648
+ window.open("/scooper-video/new/checkDevices");
14649
+ } else {
14650
+ localStorage.setItem(statusKey, checkRejected);
14651
+ }
14652
+
14653
+ return;
14654
+ }
14655
+
14656
+ if (status == checkCompleted) {
14657
+ let microResult = localStorage.getItem(microResultKey) == undefined ? resultPass : localStorage.getItem(microResultKey);
14658
+ let speakerResult = localStorage.getItem(speakerResultKey) == undefined ? resultPass : localStorage.getItem(speakerResultKey);
14659
+ let screenResult = localStorage.getItem(screenResultKey) == undefined ? resultPass : localStorage.getItem(screenResultKey);
14660
+ let msg = "";
14661
+
14662
+ if (speakerResult == resultNotPass) {
14663
+ msg += "检测到扬声器异常,可能影响系统某些功能的使用!";
14664
+ console.error(msg);
14665
+ }
14666
+
14667
+ if (microResult == resultNotPass) {
14668
+ msg += "检测到麦克风异常,可能影响系统某些功能的使用!";
14669
+ console.error(msg);
14670
+ }
14671
+
14672
+ if (screenResult === resultNotPass) {
14673
+ msg += "您的屏幕分辨率过低,可能导致页面布局混乱!"; //提示消息
14674
+
14675
+ promptAlarm(msg);
14676
+ }
14677
+
14678
+ let userAgent = navigator.userAgent;
14679
+
14680
+ if (userAgent.toLowerCase().indexOf("chrome") < 0 && userAgent.toLowerCase().indexOf("firefox") < 0 && userAgent.toLowerCase().indexOf("edge") < 0) {
14681
+ msg += "当前浏览器下部分功能可能存在兼容问题,建议使用谷歌浏览器!";
14682
+ promptAlarm(msg);
14683
+ }
14684
+
14685
+ if (msg != "") {
14686
+ //提示并派发消息
14687
+ // promptAlarm(msg);
14688
+ //防止外部未监听消息就派发事件
14689
+ setTimeout(function () {
14690
+ me.videoListener.dispatch('msginfo', {
14691
+ 'msg': msg
14692
+ });
14693
+ }, 3000);
14694
+ }
14695
+ }
14696
+ },
14697
+
14350
14698
  /**
14351
14699
  * 视频界面的初始化,在传过来的dom中创建界面
14352
14700
  */
14353
- _initVideoView: function ($dom) {
14701
+ _initVideoView: function ($dom, infoPosition) {
14354
14702
  let me = this;
14355
- let objClass = (me._opts.windowsNum == 1 ? 'video-main-full mode-' : 'video-main mode-') + me._opts.windows;
14703
+ let position;
14704
+
14705
+ switch (infoPosition) {
14706
+ case 1:
14707
+ position = "info-bottom";
14708
+ break;
14709
+
14710
+ case 2:
14711
+ position = "info-top";
14712
+ break;
14713
+
14714
+ default:
14715
+ position = "info-bottom";
14716
+ }
14717
+
14718
+ let objClass = (me._opts.windowsNum == 1 ? 'video-main video-main-full mode-' : 'video-main mode-') + me._opts.windows;
14356
14719
  let videoHtml = '<ul class="' + objClass + '" id="video-main-web-rtc" video-flag="' + me._opts.windowsBeginIndex + '">';
14357
14720
  let index = me._opts.windowsBeginIndex + 1;
14358
14721
 
14359
14722
  for (let i = index; i < index + me._opts.windowsNum; i++) {
14360
- 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>';
14723
+ 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>';
14361
14724
 
14362
14725
  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>');
14363
14726
  videoHtml += '<button type="button" class="unrecv-audio-btn hide" name="recvAudio"></button>' + '<button type="button" class="close-btn hide" name="closeVideo"></button>' + '</div>' + '</li>';
@@ -14373,7 +14736,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14373
14736
  */
14374
14737
  _initAudioView: function ($dom) {
14375
14738
  let me = this;
14376
- let objClass = (me._opts.windowsNum == 1 ? 'video-main-full mode-' : 'video-main mode-') + me._opts.windows;
14739
+ let objClass = (me._opts.windowsNum == 1 ? 'video-main video-main-full mode-' : 'video-main mode-') + me._opts.windows;
14377
14740
  let videoHtml = '<ul class="' + objClass + '" id="video-main-web-rtc" video-flag="' + me._opts.windowsBeginIndex + '">';
14378
14741
  let index = me._opts.windowsBeginIndex + 1;
14379
14742
 
@@ -14423,6 +14786,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14423
14786
  console.error('Janus服务连接失败:' + error);
14424
14787
  me.closeAll();
14425
14788
 
14789
+ me._removeAllWaitingVideo();
14790
+
14426
14791
  me._initJanus();
14427
14792
  },
14428
14793
  destroyed: function () {
@@ -14433,6 +14798,19 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14433
14798
  });
14434
14799
  },
14435
14800
 
14801
+ /**
14802
+ * 销毁所有
14803
+ */
14804
+ destory: function () {
14805
+ var me = this;
14806
+ me.destoryJanus();
14807
+ $(me.selector).empty();
14808
+ me.videoListener = null;
14809
+ me.VIDEO_DATA = null;
14810
+ me.selector = null; //destoryJanus会触发回调,需要使用到opts
14811
+ // me._opts = null;
14812
+ },
14813
+
14436
14814
  /**
14437
14815
  * 销毁:Janus销毁、资源释放
14438
14816
  */
@@ -14441,14 +14819,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14441
14819
 
14442
14820
  me._opts.janus.destroy({
14443
14821
  success: function () {
14444
- window.windowsSum = 0; //userToken = null;
14445
-
14822
+ // window.windowsSum = 0;
14823
+ //userToken = null;
14446
14824
  registered = false;
14447
14825
  },
14448
14826
  asyncRequest: true,
14449
14827
  notifyDestroyed: true
14450
14828
  });
14829
+
14830
+ me.removeAllListeners();
14451
14831
  },
14832
+ reLoginJanusItvIndex: -1,
14452
14833
 
14453
14834
  /**
14454
14835
  * 初始化插件、登陆,初始化窗口
@@ -14508,13 +14889,43 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14508
14889
 
14509
14890
  if (event === 'registration_failed') {
14510
14891
  promptFailed("janus登陆失败: " + result["code"] + " " + result["reason"]);
14892
+
14893
+ if (me.reLoginJanusItvIndex == -1) {
14894
+ me.reLoginJanusItvIndex = setInterval(function () {
14895
+ console.log("尝试重新登陆janus!");
14896
+
14897
+ me._initJanus(janus);
14898
+ }, 5000);
14899
+ }
14900
+
14901
+ return;
14902
+ }
14903
+
14904
+ if (event === 'video_server_closed') {
14905
+ if (me.reLoginJanusItvIndex == -1) {
14906
+ me.reLoginJanusItvIndex = setInterval(function () {
14907
+ console.log("尝试重新登陆janus!");
14908
+
14909
+ me._initJanus(janus);
14910
+ }, 5000);
14911
+ }
14912
+
14511
14913
  return;
14512
14914
  }
14513
14915
 
14514
14916
  if (event === 'registered') {
14515
14917
  let userToken = result["userToken"];
14516
14918
  console.log('janus登陆成功');
14517
- registered = true; //生成主界面
14919
+ registered = true;
14920
+
14921
+ if (me.reLoginJanusItvIndex != -1) {
14922
+ clearInterval(me.reLoginJanusItvIndex);
14923
+ me.reLoginJanusItvIndex = -1;
14924
+ } //生成主界面
14925
+ //相对序号,用于标识当前janus连接初始化的序号窗口
14926
+
14927
+
14928
+ let relativeIndex = 0;
14518
14929
 
14519
14930
  for (let i = me._opts.windowsBeginIndex; i < me._opts.windowsBeginIndex + me._opts.windowsNum; i++) {
14520
14931
  me.VIDEO_DATA[i] = new SVideo({
@@ -14522,42 +14933,254 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14522
14933
  janus: janus,
14523
14934
  userToken: userToken,
14524
14935
  windowsNum: me._opts.windowsNum,
14936
+ relativeIndex: relativeIndex++,
14525
14937
  flag: me._opts.flag,
14526
14938
  isVideoTag: me._opts.isVideoTag,
14527
- janusPlugin: me._opts.conf.janusPlugin
14528
- });
14939
+ janusPlugin: me._opts.conf.janusPlugin,
14940
+ videoTipTimeOut: me._opts.videoTipTimeOut,
14941
+ parentSelector: me.selector
14942
+ }, me.videoListener);
14529
14943
  }
14530
14944
  }
14531
14945
  }
14532
14946
  }
14533
14947
  });
14948
+ },
14949
+
14950
+ /* ----------------------------- 播放队列 --------------------------- */
14951
+ // 记录等待中的视频
14952
+ WAITING_DATA: [],
14953
+ // 播放队列开关 默认关闭
14954
+ waitPlayQueueSwitch: false,
14955
+
14956
+ /**
14957
+ * 添加等待视频数据
14958
+ * 同一位置再次打开,则覆盖上一次的
14959
+ * 参数:index(视频窗口编号,从0开始) video(视频设备id,即devId) id(标识,空的话使用设备id) opts(其他参数)
14960
+ */
14961
+ _addWaitingVideo: function (index, video, id, opts) {
14962
+ let _self = this;
14963
+
14964
+ let isOverride = false;
14965
+ $.each(_self.WAITING_DATA, function (i, obj) {
14966
+ if (obj.index == index) {
14967
+ console.log("播放队列中 index = " + index + ", video = " + obj.video + " 替换为 video = " + video);
14968
+ _self.WAITING_DATA[i] = {
14969
+ index: index,
14970
+ video: video,
14971
+ id: id,
14972
+ opts: opts
14973
+ };
14974
+ isOverride = true;
14975
+ return false;
14976
+ }
14977
+ });
14978
+
14979
+ if (!isOverride) {
14980
+ _self.WAITING_DATA.push({
14981
+ index: index,
14982
+ video: video,
14983
+ id: id,
14984
+ opts: opts
14985
+ });
14986
+
14987
+ console.log("index = " + index + ", video = " + video + " 加入播放队列");
14988
+ }
14989
+
14990
+ _self.VIDEO_DATA[index].isWaiting = true;
14991
+ },
14992
+
14993
+ /**
14994
+ * 删除等待视频数据
14995
+ */
14996
+ _removeWaitingVideo: function (index, video) {
14997
+ let _self = this;
14998
+
14999
+ $.each(_self.WAITING_DATA, function (i, obj) {
15000
+ if (obj.index == index && obj.video == video) {
15001
+ _self.WAITING_DATA.splice(i, 1);
15002
+
15003
+ _self.VIDEO_DATA[index].isWaiting = false;
15004
+ console.log("index = " + index + ", video = " + video + " 从播放队列移除");
15005
+ return false;
15006
+ }
15007
+ });
15008
+ },
15009
+
15010
+ /**
15011
+ * 删除所有等待播放视频的数据
15012
+ */
15013
+ _removeAllWaitingVideo: function () {
15014
+ let _self = this;
15015
+
15016
+ _self.WAITING_DATA = [];
15017
+ let index = _self._opts.windowsBeginIndex;
15018
+
15019
+ for (; index < _self._opts.windowsBeginIndex + _self._opts.windows; index++) {
15020
+ _self.VIDEO_DATA[index].isWaiting = false;
15021
+ }
15022
+ },
15023
+
15024
+ /**
15025
+ * 上一个视频关闭后,如果该位置由等待视频,通知打开新视频
15026
+ * @param index
15027
+ */
15028
+ _notifyWaitingVideo: function (index) {
15029
+ let _self = this;
15030
+
15031
+ $.each(_self.WAITING_DATA, function (i, obj) {
15032
+ if (obj.index == index) {
15033
+ _self.play(obj.index, obj.video, obj.id, obj.opts);
15034
+
15035
+ _self._removeWaitingVideo(obj.index, obj.video);
15036
+
15037
+ return false;
15038
+ }
15039
+ });
14534
15040
  }
14535
15041
  };
14536
- let FAILED_CODE = {
14537
- 1001: "账号或密码错误",
14538
- 1002: "该帐号已连接",
14539
- 1004: "没有鉴权",
14540
- 2001: "未携带token或token错误",
14541
- 2002: "视频源id不存在",
14542
- 2003: "操作指令非法(该账号不允许执行这个指令,或者不支持该指令)",
14543
- 3001: "nat通道未建立",
14544
- 3002: "该视频流已在传输",
14545
- 3003: "无法获取远端视频流",
14546
- 4001: "视频流断开连接",
14547
- 4002: "获取视频失败",
14548
- 5000: "内部错误",
14549
- 8001: "设备不支持该指令",
14550
- 453: "videoServer连接失败",
14551
- 454: "录像回放窗口已占用,请先停止播放",
14552
- 455: "无视频录像,操作失败",
14553
- 5001: "呼叫异常断开",
14554
- 5002: "禁止修改分辨率",
14555
- 4003: "音频被占用",
14556
- 4004: "音频被占用",
14557
- 4005: "客户端已打开对讲",
14558
- 4006: "终端离开云眼音频"
15042
+ let CONST_CODE = {
15043
+ //打开失败错误码,面板显示,不做浮窗提示框显示
15044
+ VIDEO_CODE: {
15045
+ 2002: "打开失败,未找到该ID的视频源",
15046
+ 2003: "打开失败,请确认视频服务版本",
15047
+ 3001: "打开失败,未接收到引流包,请检查端口映射",
15048
+ 3002: "",
15049
+ 3003: "打开失败,对方拒绝视频请求",
15050
+ 4001: "打开失败,视频流中断",
15051
+ 4002: "打开失败,终端挂机或超时未接听",
15052
+ 7000: "打开失败,无法连接视频设备",
15053
+ 7001: "打开失败,无法连接视频设备",
15054
+ 7002: "打开失败,无法连接视频设备"
15055
+ },
15056
+ OTHER_CODE: {
15057
+ 453: "videoServer连接失败,错误码453",
15058
+ 454: "视频窗口已被占用,请选择其它窗口打开或停止播放",
15059
+ 455: "操作失败,该段时间无视频录像",
15060
+ 499: "操作异常,错误码499",
15061
+ 440: "操作异常,错误码440",
15062
+ 441: "操作异常,错误码441",
15063
+ 442: "操作异常,错误码442",
15064
+ 443: "操作异常,错误码443",
15065
+ 444: "操作异常,错误码444",
15066
+ 445: "操作异常,错误码445",
15067
+ 446: "操作异常,错误码446",
15068
+ 447: "操作异常,错误码447",
15069
+ 448: "操作异常,错误码448",
15070
+ 449: "操作异常,错误码449",
15071
+ 450: "操作异常,错误码450",
15072
+ 451: "操作异常,错误码451",
15073
+ 452: "操作异常,错误码452",
15074
+ 456: "设备已处于对讲状态或不支持对讲",
15075
+ 6001: "录像失败"
15076
+ },
15077
+ FAILED_CODE: {
15078
+ 1001: "账号或密码错误",
15079
+ 1002: "该帐号已连接",
15080
+ 1004: "没有鉴权",
15081
+ 2001: "未携带token或token错误",
15082
+ 2002: "视频源id不存在",
15083
+ 2003: "操作指令非法(该账号不允许执行这个指令,或者不支持该指令)",
15084
+ 3001: "nat通道未建立",
15085
+ 3002: "该视频流已在传输",
15086
+ 3003: "无法获取远端视频流",
15087
+ 4001: "视频流异常断开连接",
15088
+ 4002: "获取视频失败",
15089
+ 5000: "内部错误",
15090
+ 8001: "该设备不支持云台操作",
15091
+ 453: "videoServer连接失败",
15092
+ 454: "录像回放窗口已占用,请先停止播放",
15093
+ 455: "无视频录像,操作失败",
15094
+ 5001: "呼叫异常断开",
15095
+ 5002: "禁止修改分辨率",
15096
+ 401: "禁止修改分辨率",
15097
+ 4003: "音频重置",
15098
+ 4004: "音频被占用",
15099
+ 4005: "客户端已打开对讲",
15100
+ 4006: "终端离开云眼音频",
15101
+ 4008: "终端拒绝打开视频",
15102
+ 6001: "录像失败",
15103
+ 499: "内部创建失败",
15104
+ 440: "请求消息内容为空",
15105
+ 441: "json格式错误",
15106
+ 442: "无效的请求",
15107
+ 443: "消息内容缺失",
15108
+ 444: "消息缺少参数",
15109
+ 445: "账户已登陆",
15110
+ 446: "收到的videoserver消息有误",
15111
+ 447: "消息参数错误",
15112
+ 448: "SDP创建失败",
15113
+ 449: "未使用",
15114
+ 450: "创建端口失败",
15115
+ 451: "SDP创建失败",
15116
+ 452: "未使用加密的RTP",
15117
+ 456: "对讲未打开",
15118
+ 7000: "URL账号密码错误(RTSP)",
15119
+ 7001: "URL地址不通(RTSP)",
15120
+ 7002: "URL格式错误(RTSP)"
15121
+ },
15122
+ STATUS_CODE_ARR: ['5002', '4003', '4004', '4005', '4006']
14559
15123
  };
14560
- let STATUS_CODE_ARR = ['5002', '4003', '4004', '4005', '4006']; //window.VIDEO_DATA = [];//记录视频各分屏的状态
15124
+ /**
15125
+ * 显示播放错误内容, 4002特殊处理
15126
+ * @param videoObj 视频对象
15127
+ * @param code 状态码(包含错误码)
15128
+ * @param isShowReplayBtn 是否显示重新播放按钮
15129
+ * @param video 打开错误的视频Id
15130
+ */
15131
+
15132
+ function showResult(videoObj, code, isShowReplayBtn, video) {
15133
+ let videoDom = videoObj.tagBox.parent();
15134
+ videoDom.addClass("result");
15135
+ videoDom.find('.operate-btn .close-btn').show();
15136
+
15137
+ if (CONST_CODE.FAILED_CODE[code] && code != "4002") {
15138
+ let resultHtml = "<div class='real-result'>错误码" + code + ": " + CONST_CODE.FAILED_CODE[code] + "</div>";
15139
+ videoDom.append(resultHtml);
15140
+ }
15141
+
15142
+ let resultHtml = "<div class='result'><div class='result-tip'>" + CONST_CODE.VIDEO_CODE[code] + "</div>";
15143
+
15144
+ if (isShowReplayBtn && code != "4002") {
15145
+ resultHtml += "<div class='result-replay'><span id='replay-" + videoObj.index + "' class='replay'>点击重试</span></div>";
15146
+ }
15147
+
15148
+ resultHtml += "</div>";
15149
+ videoDom.append(resultHtml);
15150
+
15151
+ if (isShowReplayBtn && code != "4002") {
15152
+ $("#replay-" + videoObj.index).unbind("click").click(function () {
15153
+ videoObj.videoListener.dispatch("openVideo", {
15154
+ index: videoObj.index,
15155
+ video: video,
15156
+ id: videoObj.id,
15157
+ opts: videoObj.opts
15158
+ });
15159
+ });
15160
+ }
15161
+
15162
+ if (code == "4002") {
15163
+ setTimeout(function () {
15164
+ clearResult(videoDom);
15165
+ }, 5000);
15166
+ }
15167
+ }
15168
+ /**
15169
+ * 清除显示内容 videoDom: 视频Dom对象
15170
+ */
15171
+
15172
+
15173
+ function clearResult(videoDom, videoObj) {
15174
+ videoDom.removeClass("result");
15175
+ videoDom.find(".real-result").remove();
15176
+ videoDom.find(".result").remove();
15177
+
15178
+ if (!videoObj || !videoObj.playing) {
15179
+ // bug id 18654: 增加是否正在播放判断
15180
+ videoDom.find('.operate-btn .close-btn').hide();
15181
+ }
15182
+ } //window.VIDEO_DATA = [];//记录视频各分屏的状态
15183
+
14561
15184
 
14562
15185
  window.windowsSum = 0; //当前页面的视频总数,可能有多个VideoWebRtc对象
14563
15186
  //let userToken = null;
@@ -14565,16 +15188,27 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14565
15188
  let registered = false;
14566
15189
  let recordAvBusinessId = null;
14567
15190
 
14568
- function SVideo(opts) {
15191
+ function SVideo(opts, videoListener) {
14569
15192
  this.janus = opts.janus;
14570
15193
  this.userToken = opts.userToken;
14571
15194
  this.sipcall = null;
14572
15195
  this.index = opts.index;
14573
- this.tagBox = opts.isVideoTag ? $('#video-' + (this.index + 1)) : $('#audio-' + (this.index + 1));
15196
+ this.relativeIndex = opts.relativeIndex; // this.tagBox = opts.isVideoTag ? $('#video-' + (this.index + 1)) : $('#audio-' + (this.index + 1));
15197
+
15198
+ this.tagBox = opts.isVideoTag ? $(opts.parentSelector + ' #video-' + (this.index + 1)) : $('#audio-' + (this.index + 1));
14574
15199
  this.windowsNum = opts.windowsNum;
14575
15200
  this.flag = opts.flag;
14576
15201
  this.isVideoTag = opts.isVideoTag;
14577
15202
  this.janusPlugin = opts.janusPlugin;
15203
+ this.isClosing = false; // 当前分屏是否正在关闭视频
15204
+
15205
+ this.isWaiting = false; // 当前分屏是否有视频在等待播放
15206
+
15207
+ this.playSucTimeOutIndex = -1; // 超时提示定时器index
15208
+
15209
+ this.videoTipTimeOut = opts.videoTipTimeOut; // 超时无首屏时间
15210
+
15211
+ this.videoListener = videoListener;
14578
15212
  this.init();
14579
15213
  }
14580
15214
  /**
@@ -14595,8 +15229,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14595
15229
  console.log("视频插件初始化成功:" + self.index);
14596
15230
  self.sipcall = pluginHandle;
14597
15231
 
14598
- if (self.index + 1 >= self.windowsNum) {
14599
- videoListener.dispatch('initsucc', self);
15232
+ if (self.relativeIndex + 1 >= self.windowsNum) {
15233
+ self.videoListener.dispatch('initsucc', self);
14600
15234
  }
14601
15235
  },
14602
15236
  error: function (error) {
@@ -14610,11 +15244,20 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14610
15244
  promptFailed("请先登陆");
14611
15245
  }
14612
15246
 
15247
+ let video = self.video;
15248
+
14613
15249
  if (msg.error_code) {
14614
- console.error(msg.error_code + ' ' + msg.error);
14615
- promptFailed(FAILED_CODE[msg.error_code] || '错误码:' + msg.error_code);
14616
- videoListener.dispatch('msginfo', {
14617
- 'msg': FAILED_CODE[msg.error_code] || '错误码:' + msg.error_code
15250
+ console.error("错误码:" + msg.error_code + " " + CONST_CODE.FAILED_CODE[msg.error_code]);
15251
+
15252
+ if (CONST_CODE.VIDEO_CODE[msg.error_code]) {
15253
+ showResult(self, msg.error_code, true, video);
15254
+ } else {
15255
+ promptFailed(CONST_CODE.OTHER_CODE[msg.error_code] || CONST_CODE.FAILED_CODE[msg.error_code] || '错误码:' + msg.error_code);
15256
+ }
15257
+
15258
+ self.videoListener.dispatch('msginfo', {
15259
+ 'code': msg.error_code,
15260
+ 'msg': CONST_CODE.OTHER_CODE[msg.error_code] || CONST_CODE.FAILED_CODE[msg.error_code] || '错误码:' + msg.error_code
14618
15261
  });
14619
15262
  return false;
14620
15263
  }
@@ -14624,23 +15267,32 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14624
15267
 
14625
15268
  if (result.error_code && result.error_code != 0) {
14626
15269
  //videoListener.dispatch('afterclose', self);
14627
- if (!STATUS_CODE_ARR.includes(result.error_code + '')) {
15270
+ if (!CONST_CODE.STATUS_CODE_ARR.includes(result.error_code + '')) {
14628
15271
  //videoListener.dispatch('afterclose', self);
14629
15272
  //播放失败 关闭视频
14630
- let video = self.video;
14631
15273
  self.close('err');
14632
15274
 
14633
15275
  if (self.isLockVideo) {
14634
- self.play(video);
15276
+ setTimeout(function () {
15277
+ self.play(video);
15278
+ }, 1500);
14635
15279
  } else {
14636
- videoListener.dispatch('afterclose', self);
15280
+ self.closeType = 'error';
15281
+ self.videoListener.dispatch('afterclose', self);
14637
15282
  }
14638
15283
  }
14639
15284
 
14640
- videoListener.dispatch('msginfo', {
14641
- 'msg': FAILED_CODE[result.error_code] || '错误码:' + result.error_code
15285
+ self.videoListener.dispatch('msginfo', {
15286
+ 'code': result.error_code,
15287
+ 'msg': CONST_CODE.OTHER_CODE[result.error_code] || CONST_CODE.FAILED_CODE[result.error_code] || '错误码:' + result.error_code
14642
15288
  });
14643
- promptFailed(FAILED_CODE[result.error_code] || '错误码:' + result.error_code);
15289
+
15290
+ if (CONST_CODE.VIDEO_CODE[result.error_code]) {
15291
+ showResult(self, result.error_code, true, video);
15292
+ } else {
15293
+ promptFailed(CONST_CODE.OTHER_CODE[result.error_code] || CONST_CODE.FAILED_CODE[result.error_code] || '错误码:' + result.error_code);
15294
+ }
15295
+
14644
15296
  self.tagBox.parent().find('.recv-audio-btn').attr("class", "unrecv-audio-btn");
14645
15297
  self.tagBox.parent().find('.send-audio-btn').attr("class", "unsend-audio-btn");
14646
15298
  } //事件响应
@@ -14673,17 +15325,19 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14673
15325
  });
14674
15326
  },
14675
15327
  error: function (error) {
14676
- console.error(error);
14677
- let body = {
14678
- "request": "decline",
14679
- "code": 480
14680
- };
14681
- self.sipcall.send({
14682
- "message": body
14683
- });
15328
+ console.error(error); // let body = { "request": "decline", "code": 480 };
15329
+ // self.sipcall.send({"message": body});
14684
15330
  }
14685
15331
  });
14686
15332
  break;
15333
+
15334
+ case 'accepted':
15335
+ self.playSucTimeOutIndex = setTimeout(function () {
15336
+ let _li = self.tagBox.parent();
15337
+
15338
+ _li.append('<div class="video-tip">网络环境较差,可能无法正常加载视频</div>');
15339
+ }, self.videoTipTimeOut * 1000);
15340
+ break;
14687
15341
  //呼叫失败
14688
15342
 
14689
15343
  case 'callfaild':
@@ -14702,7 +15356,16 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14702
15356
  case 'start_av_record':
14703
15357
  if (result && result.filename) {
14704
15358
  self.videoFileName = result.filename;
14705
- videoListener.dispatch('recordvideo', self);
15359
+ self.videoListener.dispatch('startRecordVideo', self);
15360
+ console.log('录像地址:' + result.filename);
15361
+ }
15362
+
15363
+ break;
15364
+
15365
+ case 'stop_av_record':
15366
+ if (result && result.filename) {
15367
+ self.videoFileName = result.filename;
15368
+ self.videoListener.dispatch('stopRecordVideo', self);
14706
15369
  console.log('录像地址:' + result.filename);
14707
15370
  }
14708
15371
 
@@ -14712,10 +15375,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14712
15375
  case 'ser_notify_resolution':
14713
15376
  if (result && result.resolution) {
14714
15377
  self.resolution = result.resolution;
14715
- videoListener.dispatch('notifyresolution', self);
15378
+ self.videoListener.dispatch('notifyresolution', self);
14716
15379
  console.log('接收notifyresolution:' + result.resolution); //promptAlarm('当前分辨率:' + result.resolution);
14717
15380
  }
14718
15381
 
15382
+ break;
15383
+
15384
+ case 'change_resolution':
15385
+ if (result) {
15386
+ self.videoListener.dispatch('notifyResolutionChange', self);
15387
+ }
15388
+
14719
15389
  break;
14720
15390
  //建立预呼叫响应
14721
15391
 
@@ -14752,9 +15422,38 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14752
15422
  break;
14753
15423
 
14754
15424
  case 'ser_stop_audio':
15425
+ self.tagBox.parent().find('.recv-audio-btn').attr("class", "unrecv-audio-btn");
14755
15426
  console.log('音频异常关闭!');
14756
15427
  break;
14757
15428
 
15429
+ case 'close_down_audio':
15430
+ self.tagBox.parent().find('.send-audio-btn').attr("class", "unsend-audio-btn");
15431
+ promptSuccess("通话时间到");
15432
+ console.log('通话时间到!');
15433
+ break;
15434
+
15435
+ case 'ser_notify_dispatch_close_ptop_poc':
15436
+ self.tagBox.parent().find('.send-audio-btn').attr("class", "unsend-audio-btn");
15437
+ console.log('调度通知点对点对讲关闭!');
15438
+ break;
15439
+
15440
+ case 'ser_close_ptop_poc':
15441
+ self.tagBox.parent().find('.send-audio-btn').attr("class", "unsend-audio-btn");
15442
+ console.log('点对点对讲关闭!');
15443
+ break;
15444
+
15445
+ case 'ser_open_ptop_poc':
15446
+ self.tagBox.parent().find('.unsend-audio-btn').attr("class", "send-audio-btn");
15447
+ console.log('点对点对讲打开!');
15448
+ break;
15449
+ // 视频关闭通知
15450
+
15451
+ case 'ser_close_video':
15452
+ console.log('视频框 ' + self.index + ' 视频已关闭');
15453
+ self.isClosing = false;
15454
+ self.videoListener.dispatch('notifyCloseVideo', self);
15455
+ break;
15456
+
14758
15457
  default:
14759
15458
  console.log('event:' + event);
14760
15459
  break;
@@ -14802,7 +15501,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14802
15501
 
14803
15502
  self.tagBox.bind("canplay play playing", function () {
14804
15503
  if (self.video) {
14805
- if (self.tagBox.is(':visible')) return;
15504
+ if (self.tagBox.is(':visible')) return; // 清除播放监测定时任务,清除内容
15505
+
15506
+ self.playSucTimeOutIndex > 0 && clearTimeout(self.playSucTimeOutIndex);
15507
+ self.tagBox.parent().find(".video-tip").remove();
14806
15508
  console.log('分屏=' + (self.index + 1) + ', ' + self.video + ' 播放成功');
14807
15509
  promptSuccess('分屏' + (self.index + 1) + ' 播放成功');
14808
15510
  self.tagBox.show(); //self.tagBox.parent().removeClass("loading").find(".stream-loading").remove();
@@ -14851,13 +15553,21 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14851
15553
  "message": body
14852
15554
  });
14853
15555
  this.video = video;
15556
+ this.isClosing = false;
14854
15557
  this.playing = true;
14855
15558
  this.packetsLostRate = '0.00%';
14856
15559
  this.packetsLostSum = 0;
14857
- this.packetsReceivedSum = 0; //loading
15560
+ this.packetsReceivedSum = 0;
15561
+ let numIndex = this.index + 1;
15562
+ let framesDecodedDom = document.getElementById("frame-decoded-" + numIndex);
15563
+ framesDecodedDom.style.display = 'none';
15564
+ this.framesDecodedLast = undefined;
15565
+ this.framesDecodedCount = 0; //loading
14858
15566
 
14859
15567
  let _li = this.tagBox.parent();
14860
15568
 
15569
+ clearResult(_li, this);
15570
+
14861
15571
  if (!_li.hasClass("loading")) {
14862
15572
  _li.addClass("loading").append('<div class="stream-loading">等待数据流传送...</div>');
14863
15573
  }
@@ -14870,8 +15580,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14870
15580
  if (!type) {
14871
15581
  this.isLockVideo = false;
14872
15582
  this.tagBox.parent().find('.lock-video-btn').attr("class", "unlock-video-btn");
14873
- } //let reqType = type ? type : "hangup";
15583
+ } //清除结果提示内容
15584
+
14874
15585
 
15586
+ clearResult(this.tagBox.parent(), this); //let reqType = type ? type : "hangup";
14875
15587
 
14876
15588
  if (!this.playing) return;
14877
15589
  let _hangup = {
@@ -14885,6 +15597,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14885
15597
  });
14886
15598
  this.sipcall.hangup();
14887
15599
  this.tagBox.hide();
15600
+ this.isClosing = true;
14888
15601
  this.playing = false;
14889
15602
  this.video = null;
14890
15603
  this.packetsLostRate = '0.00%';
@@ -14899,7 +15612,15 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
14899
15612
 
14900
15613
  this.tagBox.parent().removeClass("loading").find(".stream-loading").remove(); //清除object-fit
14901
15614
 
14902
- this.tagBox.css('object-fit', '');
15615
+ this.tagBox.css('object-fit', ''); // 清除内容提示
15616
+
15617
+ this.playSucTimeOutIndex > 0 && clearTimeout(this.playSucTimeOutIndex);
15618
+ this.tagBox.parent().find(".video-tip").remove();
15619
+ var numIndex = Number(this.index) + 1;
15620
+ var framesDecodedDom = document.getElementById("frame-decoded-" + numIndex);
15621
+ framesDecodedDom.style.display = 'none';
15622
+ this.framesDecodedLast = undefined;
15623
+ this.framesDecodedCount = 0;
14903
15624
  },
14904
15625
 
14905
15626
  /**
@@ -15004,6 +15725,8 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
15004
15725
 
15005
15726
  let _li = this.tagBox.parent();
15006
15727
 
15728
+ clearResult(_li, this);
15729
+
15007
15730
  if (!_li.hasClass("loading")) {
15008
15731
  _li.addClass("loading").append('<div class="stream-loading">等待数据流传送...</div>');
15009
15732
  }
@@ -15148,6 +15871,26 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
15148
15871
  "message": body
15149
15872
  });
15150
15873
  console.log("预呼叫操作=" + requestType + ", 对讲号码=" + pocNo + ",调度中心号码=" + centerTel);
15874
+ },
15875
+
15876
+ /**
15877
+ * 点对点对讲
15878
+ * requstType: open_ptop_poc(开启) close_poc_poc(关闭)
15879
+ * pocno
15880
+ */
15881
+ ptopPoc: function (requestType, pocNo) {
15882
+ let self = this;
15883
+ let body = {
15884
+ request: requestType,
15885
+ pocno: pocNo,
15886
+ playseq: self.index,
15887
+ pocmember: self.video,
15888
+ userToken: self.userToken
15889
+ };
15890
+ self.sipcall.send({
15891
+ "message": body
15892
+ });
15893
+ console.log("点对点对讲操作=" + requestType + ", 主叫号码=" + pocNo + ",被叫号码=" + self.video);
15151
15894
  }
15152
15895
  };
15153
15896
  return isIE() ? VideoOcx : VideoWebRtc;
@@ -28898,6 +29641,27 @@ let meet = {
28898
29641
  data: {}
28899
29642
  }
28900
29643
  },
29644
+
29645
+ /**
29646
+ * 设置主持人
29647
+ */
29648
+ setMeetChairmanNet: {
29649
+ url: '/dispatch-web/api/meet/setMeetChairman',
29650
+ method: 'POST',
29651
+ requestParam: {
29652
+ token: '',
29653
+ meetId: '',
29654
+ tel: ''
29655
+ },
29656
+ responseParam: {
29657
+ code: '',
29658
+ //返回结果状态码
29659
+ message: '',
29660
+ systemTime: '',
29661
+ //yyyy-MM-dd HH:mm:ss
29662
+ data: {}
29663
+ }
29664
+ },
28901
29665
  joinVideoMemberNet: {
28902
29666
  //成员加入会场(视频)
28903
29667
 
@@ -31500,6 +32264,20 @@ const meetOp = sip => {
31500
32264
  }, '', net.method);
31501
32265
  });
31502
32266
  },
32267
+ setChairman: function (param) {
32268
+ let net = meet_url.setMeetChairmanNet;
32269
+ return new Promise((resolve, reject) => {
32270
+ loadJson(server_ + net.url, { ...param
32271
+ }, function (ret) {
32272
+ if (ret.code == 0) {
32273
+ resolve(ret);
32274
+ } else {
32275
+ console.log("设置会场主持人失败", ret.code);
32276
+ reject(ret.code);
32277
+ }
32278
+ }, '', net.method);
32279
+ });
32280
+ },
31503
32281
  end: function (param) {
31504
32282
  let net = meet_url.endMeetNet;
31505
32283
  return new Promise((resolve, reject) => {