ucservice 1.3.5 → 1.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ucservice",
3
3
  "private": false,
4
- "version": "1.3.5",
4
+ "version": "1.3.8",
5
5
  "description": "统一通信服务",
6
6
  "main": "dist/ucservice.common.js",
7
7
  "style": "ucservice.css",
@@ -149,6 +149,18 @@
149
149
  background-size: 100% 100%;
150
150
  background-color: rgba(0,0,0,0);
151
151
  }
152
+ .rotate-btn {
153
+ position: absolute;
154
+ bottom: 1px;
155
+ right: 76px;
156
+ border: 0;
157
+ width: 28px;
158
+ height: 28px;
159
+ float: left;
160
+ /* background-image: url("~@/img/yy_gb.png"); */
161
+ background-size: 100% 100%;
162
+ background-color: rgba(0,0,0,0);
163
+ }
152
164
  .recv-audio-btn {
153
165
  position: absolute;
154
166
  bottom: -8px;
@@ -189,7 +189,8 @@ let location = {
189
189
  method: 'POST',
190
190
  requestParam: {
191
191
  mapId: '', //地图类型
192
- layers: '' //设备类型
192
+ kw: '', //关键字
193
+ layers: '' //设备类型 可选
193
194
  },
194
195
  responseParam: {
195
196
  code: '', //返回结果状态码
@@ -612,7 +612,9 @@
612
612
  me.dispatch('screenchange',{windowNums: num});
613
613
  me._opts.windows = num;
614
614
  me._opts.extra = extra;
615
-
615
+
616
+ //设置旋转了的视频样式
617
+
616
618
  },
617
619
 
618
620
  /**
@@ -1583,14 +1585,21 @@
1583
1585
  me.setChoiceWindow(me._getMinIndexFreeWindow());
1584
1586
  }
1585
1587
 
1586
- $('[video-flag="'+me._opts.windowsBeginIndex+'"]').removeClass("mode-" + me._opts.windows).addClass("mode-" + num);
1587
- let _li = $('[video-flag="'+me._opts.windowsBeginIndex+'"]>li').hide();
1588
- me._opts.windows = num;
1589
- for(let i = 0; i < num; i++){
1590
- _li.eq(i).show();
1591
- }
1592
- //分屏切换事件
1593
- this.dispatch('screenchange', {windowNums:num, flag:me._opts.flag});
1588
+ $('[video-flag="'+me._opts.windowsBeginIndex+'"]').removeClass("mode-" + me._opts.windows).addClass("mode-" + num);
1589
+ let _li = $('[video-flag="'+me._opts.windowsBeginIndex+'"]>li').hide();
1590
+ me._opts.windows = num;
1591
+ for(let i = 0; i < num; i++){
1592
+ _li.eq(i).show();
1593
+ }
1594
+ //分屏切换事件
1595
+ this.dispatch('screenchange', {windowNums:num, flag:me._opts.flag});
1596
+
1597
+ //设置旋转视频的样式
1598
+ for(let k = 0; k < _li.length; k++){
1599
+ let rotateIndex = _li.eq(k).find('button[name=rotateVideo]').attr('rotate-index');
1600
+ if(rotateIndex != 0 && rotateIndex != 2)
1601
+ videoRotateSize(_li.eq(k), rotateIndex);
1602
+ }
1594
1603
  },
1595
1604
 
1596
1605
  /**
@@ -2004,6 +2013,11 @@
2004
2013
  */
2005
2014
  _init: function($dom,opts){
2006
2015
  let me = this;
2016
+ //保存dom元素的selector用作后续所有子集对象的定位(在多组件对讲模式下有用)
2017
+ if($dom.length == 0 || !me.getDomSelector($dom)) {
2018
+ console.error("父doom元素为空,无法进行视频初始化", $dom);
2019
+ return ;
2020
+ }
2007
2021
  //配置项
2008
2022
  me._opts = {
2009
2023
  windows: 4,
@@ -2049,12 +2063,126 @@
2049
2063
  //双击某个视频全屏
2050
2064
  me._dbClickFullScreen();
2051
2065
  },
2066
+
2067
+ videoRotateSize(li, rotateIndex){
2068
+ let video = li.querySelector('video');
2069
+ let videoWidth = video.videoWidth;
2070
+ let videoHeight = video.videoHeight;
2071
+ let vWidth = video.offsetWidth
2072
+ let vHeight = video.offsetHeight
2073
+ let liWidth = li.offsetWidth;
2074
+ let liHeight = li.offsetHeight;
2075
+ if(rotateIndex == 0){ //0
2076
+ $(video).attr('class', 'video-box');
2077
+ $(video).css('height', '');
2078
+ $(video).css('width', 'auto');
2079
+ video.style.position = 'static';
2080
+ video.style.transform = 'none';
2081
+ $(video).css('left', '');
2082
+ $(video).css('top', '');
2083
+ }else if(rotateIndex == 3){ //3
2084
+ $(video).attr('class', 'video-box');
2085
+ video.style.position = 'absolute';
2086
+ video.style.transform = 'rotate(270deg)';
2087
+ if(videoWidth / videoHeight > liWidth / liHeight){ //视频横向留白
2088
+ $(video).css('width', liHeight);
2089
+ $(video).css('height', 'auto');
2090
+ $(video).css('left', 'calc(' + liWidth + ' / 2' + ' - ' + liHeight + ' / 2)');
2091
+ $(video).css('top', 'calc(-' + liHeight / 2 + ' / ' + vWidth + ' * ' + vHeight + ' + ' + liHeight + ' / 2)');
2092
+ }else { //视频纵向留白
2093
+ $(video).css('height', liWidth);
2094
+ $(video).css('width', 'auto');
2095
+ $(video).css('left', 'calc(' + liHeight + ' / 2' + ' - ' + liWidth + ' / 2)');
2096
+ $(video).css('top', 'calc(-' + liWidth / 2 + ' / ' + vHeight + ' * ' + vWidth + ' + ' + liWidth + ' / 2)');
2097
+ }
2098
+ }else if(rotateIndex == 2){ //2
2099
+ $(video).attr('class', 'video-box');
2100
+ $(video).css('height', '');
2101
+ $(video).css('width', 'auto');
2102
+ video.style.position = 'static';
2103
+ video.style.transform = 'rotate(180deg)';
2104
+ $(video).css('left', '');
2105
+ $(video).css('top', '');
2106
+ }else if(rotateIndex == 1){ //1
2107
+ $(video).attr('class', 'video-box');
2108
+ video.style.position = 'absolute';
2109
+ video.style.transform = 'rotate(90deg)';
2110
+ if(videoWidth / videoHeight > liWidth / liHeight){ //视频横向留白
2111
+ $(video).css('width', liHeight);
2112
+ $(video).css('height', 'auto');
2113
+ $(video).css('left', 'calc(' + liWidth + ' / 2' + ' - ' + liHeight + ' / 2)');
2114
+ $(video).css('top', 'calc(-' + liHeight / 2 + ' / ' + vWidth + ' * ' + vHeight + ' + ' + liHeight + ' / 2)');
2115
+ }else { //视频纵向留白
2116
+ $(video).css('height', liWidth);
2117
+ $(video).css('width', 'auto');
2118
+ $(video).css('left', 'calc(' + liHeight + ' / 2' + ' - ' + liWidth + ' / 2)');
2119
+ $(video).css('top', 'calc(-' + liWidth / 2 + ' / ' + vHeight + ' * ' + vWidth + ' + ' + liWidth + ' / 2)');
2120
+ }
2121
+ }
2122
+ },
2123
+ /**
2124
+ * 获取父窗口传入dom的唯一selector(针对jquery高版本dom对象没有selector属性的问题)
2125
+ * @param $dom
2126
+ * @return {boolean}
2127
+ */
2128
+ getDomSelector: function($dom) {
2129
+ var me = this;
2130
+ if($dom.selector) {
2131
+ me.selector = $dom.selector;
2132
+ }
2133
+ else {
2134
+ if($dom.attr("id")) {
2135
+ me.selector = "#" + $dom.attr("id");
2136
+ }
2137
+ else {
2138
+ if(!$dom.attr("class")) return false;
2139
+ var classNames = $dom.attr("class").split(/\s+/);
2140
+ $.each(classNames, function (i, className) {
2141
+ if ($("." + className).length == 1) {
2142
+ me.selector = "." + className;
2143
+ return true;
2144
+ }
2145
+ });
2146
+ }
2147
+ }
2148
+ if(!me.selector) return false;
2149
+ else return true;
2150
+ },
2052
2151
 
2053
2152
  /**
2054
2153
  * 初始化按钮点击事件
2055
2154
  */
2056
2155
  _initBtnEvent: function() {
2057
2156
  let me = this;
2157
+
2158
+ // 设置视频窗可拖拽
2159
+ var src = null;
2160
+ $(me.selector + ' li').bind("dragstart", function (ev) {
2161
+ src = $(this);
2162
+ })
2163
+
2164
+ $(me.selector + ' li').bind("dragover", function (ev) {
2165
+ ev.preventDefault();
2166
+ })
2167
+
2168
+ $(me.selector + ' li').bind("drop", function (ev) {
2169
+ ev.preventDefault();
2170
+ if(src.prop("outerHTML") === $(this).prop("outerHTML")){
2171
+ return;
2172
+ }
2173
+ var target = $(this);
2174
+ var srcIndex = src.index();
2175
+ var targetIndex = target.index();
2176
+
2177
+ if (srcIndex > targetIndex) {
2178
+ src.insertBefore(target);
2179
+ target.insertAfter($(me.selector +' .video-main li.screen').eq(srcIndex));
2180
+ } else {
2181
+ src.insertAfter(target);
2182
+ target.insertBefore($(me.selector +' .video-main li.screen').eq(srcIndex));
2183
+ }
2184
+ })
2185
+
2058
2186
  let videoFlagObj = $('[video-flag="'+me._opts.windowsBeginIndex+'"]');
2059
2187
 
2060
2188
  //锁定视频事件
@@ -2074,6 +2202,13 @@
2074
2202
  $(this).attr('class', 'lock-video-btn');
2075
2203
  }
2076
2204
  });
2205
+ videoFlagObj.find('button[name=rotateVideo]').click(function(){
2206
+ let rotateIndex = Number($(this).attr("rotate-index"));
2207
+ rotateIndex++
2208
+ $(this).attr("rotate-index", rotateIndex % 4);
2209
+ let li = $(this).parent().parent()[0];
2210
+ videoRotateSize(li, rotateIndex)
2211
+ })
2077
2212
 
2078
2213
  //接收音频事件
2079
2214
  videoFlagObj.find("button[name='recvAudio']").click(function(){
@@ -2303,7 +2438,7 @@
2303
2438
  '<div class="info hide" id="info-' + i +'"></div>' +
2304
2439
  '<div class="operate-btn">';
2305
2440
  //videoHtml +='<button type="button" class="unlock-video-btn hide" name="lockVideo"></button>';
2306
- checkUserMediaAvailable() && (videoHtml += '<button type="button" class="unsend-audio-btn hide" name="sendAudio"></button>');
2441
+ checkUserMediaAvailable() && (videoHtml += '<button type="button" class="rotate-btn hide" name="rotateVideo" rotate-index="0"></button><button type="button" class="unsend-audio-btn hide" name="sendAudio"></button>');
2307
2442
  videoHtml += '<button type="button" class="unrecv-audio-btn hide" name="recvAudio"></button>' +
2308
2443
  '<button type="button" class="close-btn hide" name="closeVideo"></button>' +
2309
2444
  '</div>' +