正在显示
2 个修改的文件
包含
60 行增加
和
3 行删除
| @@ -62,7 +62,7 @@ export default class MessageEntrance extends Emiter { | @@ -62,7 +62,7 @@ export default class MessageEntrance extends Emiter { | ||
| 62 | constructor() { | 62 | constructor() { |
| 63 | super(); | 63 | super(); |
| 64 | //sdk 信息 | 64 | //sdk 信息 |
| 65 | - GlobalConfig.sdkVersion = "v2.16.5.20171012"; | 65 | + GlobalConfig.sdkVersion = "v2.16.8.20171012"; |
| 66 | loger.warn("sdkVersion:" + GlobalConfig.sdkVersion); | 66 | loger.warn("sdkVersion:" + GlobalConfig.sdkVersion); |
| 67 | 67 | ||
| 68 | //设置 | 68 | //设置 |
| @@ -194,19 +194,28 @@ class WebRtcApe extends Emiter { | @@ -194,19 +194,28 @@ class WebRtcApe extends Emiter { | ||
| 194 | userName = user.name || "unknow"; | 194 | userName = user.name || "unknow"; |
| 195 | userRole = user.userRole; | 195 | userRole = user.userRole; |
| 196 | } | 196 | } |
| 197 | - let nameDiv = `<div style="width:98%;height:20px; position: absolute;bottom: 0; z-index: 1;left: 4px;overflow:hidden;font-size: 14px;text-align: right; color: #cccccc;display:${this.nameDisplay}">${userName}</div>`; | 197 | + |
| 198 | + //添加之前先删除之前存在的重复视图 | ||
| 199 | + let len=$("#"+this.xdyRemote + uid+" #player_" + uid).length; | ||
| 200 | + if(len<1){ | ||
| 201 | + loger.log("添加之前先删除之前存在的重复视图",uid); | ||
| 202 | + $("#"+this.xdyRemote + uid).remove(); | ||
| 203 | + } | ||
| 198 | 204 | ||
| 199 | if (userRole == ApeConsts.invisible) { | 205 | if (userRole == ApeConsts.invisible) { |
| 206 | + let nameDiv = `<div style=${this.invisibleVideoWidth}px;height:20px; position: absolute;bottom: 0; z-index: 1;overflow:hidden;font-size: 14px;text-align: right; color: #cccccc;display:${this.nameDisplay}">${userName}</div>`; | ||
| 200 | //把远程视频添加到监课列表 | 207 | //把远程视频添加到监课列表 |
| 201 | loger.log("获取远程视频流成功->监课:" + userName + "->" + uid, new Date().getTime()); | 208 | loger.log("获取远程视频流成功->监课:" + userName + "->" + uid, new Date().getTime()); |
| 202 | let viewDiv = `<div id="${this.xdyRemote + uid}" class="${this.invisibleWebRtcVideoClass}" style="width:${this.invisibleVideoWidth*this.videoScale}px;height:${this.invisibleVideoHeight*this.videoScale}px;float: left;margin-right: 1px;pointer-events: none;">${nameDiv}</div>`; | 209 | let viewDiv = `<div id="${this.xdyRemote + uid}" class="${this.invisibleWebRtcVideoClass}" style="width:${this.invisibleVideoWidth*this.videoScale}px;height:${this.invisibleVideoHeight*this.videoScale}px;float: left;margin-right: 1px;pointer-events: none;">${nameDiv}</div>`; |
| 203 | $(this.invisibleViewId).append(viewDiv); | 210 | $(this.invisibleViewId).append(viewDiv); |
| 204 | } else if (userRole == ApeConsts.host||userRole == ApeConsts.assistant||userRole == ApeConsts.presenter) { | 211 | } else if (userRole == ApeConsts.host||userRole == ApeConsts.assistant||userRole == ApeConsts.presenter) { |
| 212 | + let nameDiv = `<div style="width:${this.hostRemoteVideoWidth}px;height:20px; position: absolute;bottom: 0; z-index: 1;overflow:hidden;font-size: 14px;text-align: right; color: #cccccc;display:${this.nameDisplay}">${userName}</div>`; | ||
| 205 | //把远程视图添加到老师列表 | 213 | //把远程视图添加到老师列表 |
| 206 | loger.log("获取远程视频流成功->userRole:"+userRole+":" + userName + "->" + uid, new Date().getTime()); | 214 | loger.log("获取远程视频流成功->userRole:"+userRole+":" + userName + "->" + uid, new Date().getTime()); |
| 207 | let viewDiv = `<div id="${this.xdyRemote + uid}" class="${this.hostWebRtcVideoClass}" style="width:${this.hostRemoteVideoWidth*this.videoScale}px;height:${this.hostRemoteVideoHeight*this.videoScale}px;float: left;margin-right: 1px;pointer-events: none;">${nameDiv}</div>`; | 215 | let viewDiv = `<div id="${this.xdyRemote + uid}" class="${this.hostWebRtcVideoClass}" style="width:${this.hostRemoteVideoWidth*this.videoScale}px;height:${this.hostRemoteVideoHeight*this.videoScale}px;float: left;margin-right: 1px;pointer-events: none;">${nameDiv}</div>`; |
| 208 | $(this.hostRemoteViewId).prepend(viewDiv); | 216 | $(this.hostRemoteViewId).prepend(viewDiv); |
| 209 | } else { | 217 | } else { |
| 218 | + let nameDiv = `<div style="width:${this.normalRemoteVideoWidth}px;height:20px; position: absolute;bottom: 0; z-index: 1;overflow:hidden;font-size: 14px;text-align: right; color: #cccccc;display:${this.nameDisplay}">${userName}</div>`; | ||
| 210 | //把视图添加到学生列表 | 219 | //把视图添加到学生列表 |
| 211 | loger.log("获取远程视频流成功->学生:" + userName + "->" + uid, new Date().getTime()); | 220 | loger.log("获取远程视频流成功->学生:" + userName + "->" + uid, new Date().getTime()); |
| 212 | let viewDiv = `<div id="${this.xdyRemote + uid}" class="${this.normalWebRtcVideoClass}" style="width:${this.normalRemoteVideoWidth*this.videoScale}px;height:${this.normalRemoteVideoHeight*this.videoScale}px;float: left;margin-right: 1px;pointer-events: none;">${nameDiv}</div>`; | 221 | let viewDiv = `<div id="${this.xdyRemote + uid}" class="${this.normalWebRtcVideoClass}" style="width:${this.normalRemoteVideoWidth*this.videoScale}px;height:${this.normalRemoteVideoHeight*this.videoScale}px;float: left;margin-right: 1px;pointer-events: none;">${nameDiv}</div>`; |
| @@ -217,12 +226,59 @@ class WebRtcApe extends Emiter { | @@ -217,12 +226,59 @@ class WebRtcApe extends Emiter { | ||
| 217 | $("bar_" + stream.getId()).hide(); | 226 | $("bar_" + stream.getId()).hide(); |
| 218 | stream.play(this.xdyRemote + stream.getId()); | 227 | stream.play(this.xdyRemote + stream.getId()); |
| 219 | } catch (err) { | 228 | } catch (err) { |
| 229 | + //添加之前先删除之前存在的重复视图 | ||
| 230 | + let len=$("#"+this.xdyRemote + uid+" #player_" + uid).length; | ||
| 231 | + if(len<1){ | ||
| 232 | + lloger.log("流播放失败->删除视图",uid); | ||
| 233 | + $("#"+this.xdyRemote + uid).remove(); | ||
| 234 | + } | ||
| 220 | } | 235 | } |
| 221 | if (user && (user.deviceType == 1 || user.deviceType == 2)) { | 236 | if (user && (user.deviceType == 1 || user.deviceType == 2)) { |
| 222 | this.remoteVideoList[user.nodeId] = stream; | 237 | this.remoteVideoList[user.nodeId] = stream; |
| 223 | } | 238 | } |
| 224 | } | 239 | } |
| 240 | + | ||
| 241 | + this.clearInvalidVideoView(); | ||
| 225 | } | 242 | } |
| 243 | + //清除无效的视图 | ||
| 244 | + clearInvalidVideoView(){ | ||
| 245 | + let normalList=document.getElementsByClassName(this.normalWebRtcVideoClass); | ||
| 246 | + let hostList=document.getElementsByClassName(this.hostWebRtcVideoClass); | ||
| 247 | + let localList=document.getElementsByClassName(this.localWebRtcVideoClass); | ||
| 248 | + | ||
| 249 | + let divItem=null; | ||
| 250 | + if(normalList){ | ||
| 251 | + for (let i=normalList.length-1;i>=0;i--){ | ||
| 252 | + divItem=normalList[i]; | ||
| 253 | + if(divItem&&divItem.children.length<2){ | ||
| 254 | + console.log("删除无效的视图",divItem); | ||
| 255 | + divItem.remove(); | ||
| 256 | + } | ||
| 257 | + } | ||
| 258 | + } | ||
| 259 | + divItem=null; | ||
| 260 | + if(hostList){ | ||
| 261 | + for (let i=hostList.length-1;i>=0;i--){ | ||
| 262 | + divItem=hostList[i]; | ||
| 263 | + if(divItem&&divItem.children.length<2){ | ||
| 264 | + console.log("删除无效的视图",divItem); | ||
| 265 | + divItem.remove(); | ||
| 266 | + } | ||
| 267 | + } | ||
| 268 | + } | ||
| 269 | + divItem=null; | ||
| 270 | + if(localList){ | ||
| 271 | + for (let i=localList.length-1;i>=0;i--){ | ||
| 272 | + divItem=localList[i]; | ||
| 273 | + if(divItem&&divItem.children.length<2){ | ||
| 274 | + console.log("删除无效的视图",divItem); | ||
| 275 | + divItem.remove(); | ||
| 276 | + } | ||
| 277 | + } | ||
| 278 | + } | ||
| 279 | + divItem=null; | ||
| 280 | + } | ||
| 281 | + | ||
| 226 | 282 | ||
| 227 | //重新添加远程视频 | 283 | //重新添加远程视频 |
| 228 | reAddRemoteStream(_stream) { | 284 | reAddRemoteStream(_stream) { |
| @@ -263,7 +319,8 @@ class WebRtcApe extends Emiter { | @@ -263,7 +319,8 @@ class WebRtcApe extends Emiter { | ||
| 263 | //console.log("remoteView->", remoteView) | 319 | //console.log("remoteView->", remoteView) |
| 264 | if (remoteView) { | 320 | if (remoteView) { |
| 265 | let player = document.getElementById("player_" + nodeId); | 321 | let player = document.getElementById("player_" + nodeId); |
| 266 | - if (player) { | 322 | + let len=$("#"+this.xdyRemote + nodeId+" #player_" + nodeId).length; |
| 323 | + if (len>0) { | ||
| 267 | loger.log(nodeId + " 流已经添加显示,不需要再处理"); | 324 | loger.log(nodeId + " 流已经添加显示,不需要再处理"); |
| 268 | return; | 325 | return; |
| 269 | } else { | 326 | } else { |
-
请 注册 或 登录 后发表评论