1.修改Saas开启音视频录制接口的参数;2.webRtc模块增加视频所有者的名称显示;3.新增接口,根据用户的nodeId查找用户信息
正在显示
4 个修改的文件
包含
61 行增加
和
39 行删除
| @@ -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.5.8.20170915"; | 65 | + GlobalConfig.sdkVersion = "v2.5.12.20170915"; |
| 66 | loger.warn("sdkVersion:" + GlobalConfig.sdkVersion); | 66 | loger.warn("sdkVersion:" + GlobalConfig.sdkVersion); |
| 67 | 67 | ||
| 68 | //设置 | 68 | //设置 |
| @@ -165,7 +165,12 @@ class GlobalConfig { | @@ -165,7 +165,12 @@ class GlobalConfig { | ||
| 165 | }else { | 165 | }else { |
| 166 | return "normal" | 166 | return "normal" |
| 167 | } | 167 | } |
| 168 | - | 168 | + } |
| 169 | + /* | ||
| 170 | + * 根据nodeId获取用户的信息 | ||
| 171 | + * */ | ||
| 172 | + static getUserInfoFromeNodeId(_nodeId){ | ||
| 173 | + return this.rosters[_nodeId]; | ||
| 169 | } | 174 | } |
| 170 | // 判断自己是否主持人角色 | 175 | // 判断自己是否主持人角色 |
| 171 | static get isHost() { | 176 | static get isHost() { |
| @@ -602,14 +602,34 @@ class Sass extends Emiter { | @@ -602,14 +602,34 @@ class Sass extends Emiter { | ||
| 602 | loger.log("调用服务器端开启录制->失败->接口地址无效"); | 602 | loger.log("调用服务器端开启录制->失败->接口地址无效"); |
| 603 | return; | 603 | return; |
| 604 | } | 604 | } |
| 605 | + /* { | ||
| 606 | + "appId": "xxxxxxx", | ||
| 607 | + "channel": "xxxxx_xxxx", | ||
| 608 | + "channelKey": "xxxxxx", | ||
| 609 | + "uid": 11111, | ||
| 610 | + "userId": "xxx", | ||
| 611 | + "userName": "xxx", | ||
| 612 | + "userRole": "xxx", | ||
| 613 | + "timestamp": "发送消息的的客户端时间戳", | ||
| 614 | + "recordTimestamp": "当前录制进行的时间戳(回放时使用)" | ||
| 615 | + }*/ | ||
| 605 | //{"appId":"eb253cc7b40c4a8b82f0a5b6f93c2ce0","channel":"testcdn_580908347","channelKey":null,"uid":594312157} //录制的channelKey是appCertificate | 616 | //{"appId":"eb253cc7b40c4a8b82f0a5b6f93c2ce0","channel":"testcdn_580908347","channelKey":null,"uid":594312157} //录制的channelKey是appCertificate |
| 606 | let url=GlobalConfig.locationProtocol+GlobalConfig.recordInterfaces; | 617 | let url=GlobalConfig.locationProtocol+GlobalConfig.recordInterfaces; |
| 618 | + let curTimestamp= new Date().getTime(); | ||
| 607 | fetch(encodeURI(url), { | 619 | fetch(encodeURI(url), { |
| 608 | method: 'POST', | 620 | method: 'POST', |
| 609 | headers: { | 621 | headers: { |
| 610 | "Content-Type": "application/x-www-form-urlencoded" | 622 | "Content-Type": "application/x-www-form-urlencoded" |
| 611 | }, | 623 | }, |
| 612 | - body: `appId=${GlobalConfig.appId}&channel=${GlobalConfig.channelId}&channelKey=${GlobalConfig.appCertificate}&uid=${GlobalConfig.userUid}`, | 624 | + body: `appId=${GlobalConfig.appId} |
| 625 | + &channel=${GlobalConfig.channelId} | ||
| 626 | + &channelKey=${GlobalConfig.appCertificate} | ||
| 627 | + &uid=${GlobalConfig.userUid} | ||
| 628 | + &userId=${GlobalConfig.userId} | ||
| 629 | + &userName=${GlobalConfig.userName} | ||
| 630 | + &userRole=${GlobalConfig.userRole} | ||
| 631 | + ×tamp=${curTimestamp} | ||
| 632 | + &recordTimestamp=${GlobalConfig.recordTimestamp}`, | ||
| 613 | timeout: 4000 | 633 | timeout: 4000 |
| 614 | }) | 634 | }) |
| 615 | .then(ret => { | 635 | .then(ret => { |
| @@ -630,32 +650,9 @@ class Sass extends Emiter { | @@ -630,32 +650,9 @@ class Sass extends Emiter { | ||
| 630 | .catch(err => { | 650 | .catch(err => { |
| 631 | loger.error(`调用服务器端开启录制.状态码:${err}`); | 651 | loger.error(`调用服务器端开启录制.状态码:${err}`); |
| 632 | }); | 652 | }); |
| 633 | - | ||
| 634 | - /*let userIpInfo={ | ||
| 635 | - "appID":GlobalConfig.appId, | ||
| 636 | - "channel":GlobalConfig.channelId, | ||
| 637 | - "channelKey": GlobalConfig.channelKey, | ||
| 638 | - "uid": GlobalConfig.userUid | ||
| 639 | - } | ||
| 640 | - let location=GlobalConfig.recordInterfaces;//'http://123.56.73.119:3000/users/Recording'; | ||
| 641 | - loger.log("调用服务器端开启录制->",location,userIpInfo); | ||
| 642 | - $.ajax( | ||
| 643 | - { | ||
| 644 | - type:'post', | ||
| 645 | - url : location, | ||
| 646 | - dataType : 'json', | ||
| 647 | - data: userIpInfo, | ||
| 648 | - success : function(data) { | ||
| 649 | - loger.log("调用服务器端开启录制->success",data); | ||
| 650 | - }, | ||
| 651 | - error : function(data) { | ||
| 652 | - //alert(data.code); | ||
| 653 | - loger.log("调用服务器端开启录制->error",data); | ||
| 654 | - } | ||
| 655 | - } | ||
| 656 | - );*/ | ||
| 657 | } | 653 | } |
| 658 | 654 | ||
| 655 | + | ||
| 659 | //答题卡------------------------------------------------------- | 656 | //答题卡------------------------------------------------------- |
| 660 | //创建答题数据 | 657 | //创建答题数据 |
| 661 | creatQuestion(_param) { | 658 | creatQuestion(_param) { |
| @@ -14,6 +14,7 @@ let loger = Loger.getLoger('WebRtcApe'); | @@ -14,6 +14,7 @@ let loger = Loger.getLoger('WebRtcApe'); | ||
| 14 | class WebRtcApe extends Emiter { | 14 | class WebRtcApe extends Emiter { |
| 15 | constructor() { | 15 | constructor() { |
| 16 | super(); | 16 | super(); |
| 17 | + this.nameDisplay="block";//默认显示名字 | ||
| 17 | this.appId = ''; | 18 | this.appId = ''; |
| 18 | this.appCertificate = ""; | 19 | this.appCertificate = ""; |
| 19 | this.appRecordingKey = ""; | 20 | this.appRecordingKey = ""; |
| @@ -122,28 +123,37 @@ class WebRtcApe extends Emiter { | @@ -122,28 +123,37 @@ class WebRtcApe extends Emiter { | ||
| 122 | let stream = evt.stream; | 123 | let stream = evt.stream; |
| 123 | if(stream){ | 124 | if(stream){ |
| 124 | //let viewDiv=`<div id="${this.xdyRemote + stream.getId()}" style="width:${this.hostRemoteVideoWidth}px;height:${this.hostRemoteVideoHeight}px;"></div>`; | 125 | //let viewDiv=`<div id="${this.xdyRemote + stream.getId()}" style="width:${this.hostRemoteVideoWidth}px;height:${this.hostRemoteVideoHeight}px;"></div>`; |
| 125 | - if(GlobalConfig.getUserRoleFromeNodeId(stream.getId())==ApeConsts.invisible){ | 126 | + let uid=stream.getId(); |
| 127 | + let user=GlobalConfig.getUserInfoFromeNodeId(uid); | ||
| 128 | + let userName=""; | ||
| 129 | + let userRole="" | ||
| 130 | + if(user){ | ||
| 131 | + userName=user.name||""; | ||
| 132 | + userRole=user.userRole; | ||
| 133 | + } | ||
| 134 | + let nameDiv=`<div style="width:98%;height:20px; position: absolute; z-index: 1;left: 4px;overflow:hidden;font-size: 14px; color: #cccccc;display:${this.nameDisplay}">${userName}</div>`; | ||
| 135 | + | ||
| 136 | + if(userRole==ApeConsts.invisible){ | ||
| 126 | //把远程视频添加到监课列表 | 137 | //把远程视频添加到监课列表 |
| 127 | - loger.log("获取远程视频流成功->监课:" + stream.getId(),new Date().getTime()); | ||
| 128 | - let viewDiv=`<div id="${this.xdyRemote + stream.getId()}" style="width:${this.invisibleVideoWidth}px;height:${this.invisibleVideoHeight}px;float: left;margin-right: 1px;pointer-events: none;"></div>`; | 138 | + loger.log("获取远程视频流成功->监课:"+userName+"->" + uid,new Date().getTime()); |
| 139 | + let viewDiv=`<div id="${this.xdyRemote + uid}" style="width:${this.invisibleVideoWidth}px;height:${this.invisibleVideoHeight}px;float: left;margin-right: 1px;pointer-events: none;">${nameDiv}</div>`; | ||
| 129 | $(this.invisibleViewId).append(viewDiv); | 140 | $(this.invisibleViewId).append(viewDiv); |
| 130 | - }else if(GlobalConfig.getUserRoleFromeNodeId(stream.getId())==ApeConsts.host){ | 141 | + }else if(userRole==ApeConsts.host){ |
| 131 | //把远程视图添加到老师列表 | 142 | //把远程视图添加到老师列表 |
| 132 | - loger.log("获取远程视频流成功->老师:" + stream.getId(),new Date().getTime()); | ||
| 133 | - let viewDiv=`<div id="${this.xdyRemote + stream.getId()}" style="width:${this.hostRemoteVideoWidth}px;height:${this.hostRemoteVideoHeight}px;float: left;margin-right: 1px;pointer-events: none;"></div>`; | 143 | + loger.log("获取远程视频流成功->老师:"+userName+"->" + uid,new Date().getTime()); |
| 144 | + let viewDiv=`<div id="${this.xdyRemote + uid}" style="width:${this.hostRemoteVideoWidth}px;height:${this.hostRemoteVideoHeight}px;float: left;margin-right: 1px;pointer-events: none;">${nameDiv}</div>`; | ||
| 134 | $(this.hostRemoteViewId).append(viewDiv); | 145 | $(this.hostRemoteViewId).append(viewDiv); |
| 135 | }else { | 146 | }else { |
| 136 | //把视图添加到学生列表 | 147 | //把视图添加到学生列表 |
| 137 | - loger.log("获取远程视频流成功->学生:" + stream.getId(),new Date().getTime()); | ||
| 138 | - let viewDiv=`<div id="${this.xdyRemote + stream.getId()}" style="width:${this.normalRemoteVideoWidth}px;height:${this.normalRemoteVideoHeight}px;float: left;margin-right: 1px;pointer-events: none;"></div>`; | 148 | + loger.log("获取远程视频流成功->学生:"+userName+"->" +uid,new Date().getTime()); |
| 149 | + let viewDiv=`<div id="${this.xdyRemote + uid}" style="width:${this.normalRemoteVideoWidth}px;height:${this.normalRemoteVideoHeight}px;float: left;margin-right: 1px;pointer-events: none;">${nameDiv}</div>`; | ||
| 139 | $(this.normalRemoteViewId).append(viewDiv); | 150 | $(this.normalRemoteViewId).append(viewDiv); |
| 140 | } | 151 | } |
| 141 | - //播放视频 | 152 | + //播放视频,隐藏控制条 |
| 142 | try{ | 153 | try{ |
| 143 | $("bar_"+stream.getId()).hide(); | 154 | $("bar_"+stream.getId()).hide(); |
| 144 | stream.play(this.xdyRemote + stream.getId()); | 155 | stream.play(this.xdyRemote + stream.getId()); |
| 145 | }catch (err){ | 156 | }catch (err){ |
| 146 | - | ||
| 147 | } | 157 | } |
| 148 | } | 158 | } |
| 149 | 159 | ||
| @@ -253,7 +263,6 @@ class WebRtcApe extends Emiter { | @@ -253,7 +263,6 @@ class WebRtcApe extends Emiter { | ||
| 253 | return; | 263 | return; |
| 254 | } | 264 | } |
| 255 | this.localStream.init(()=> { | 265 | this.localStream.init(()=> { |
| 256 | - //let viewName = this.localViewId.replace("#", ""); | ||
| 257 | let viewName='localVideoBox_'+this.uid; | 266 | let viewName='localVideoBox_'+this.uid; |
| 258 | let videoBox=document.createElement("div"); | 267 | let videoBox=document.createElement("div"); |
| 259 | videoBox.id=viewName; | 268 | videoBox.id=viewName; |
| @@ -262,9 +271,18 @@ class WebRtcApe extends Emiter { | @@ -262,9 +271,18 @@ class WebRtcApe extends Emiter { | ||
| 262 | videoBox.style.float='left'; | 271 | videoBox.style.float='left'; |
| 263 | videoBox.style.marginRight="1px"; | 272 | videoBox.style.marginRight="1px"; |
| 264 | videoBox.style.pointerEvents='none'; | 273 | videoBox.style.pointerEvents='none'; |
| 265 | - $(this.localViewId).prepend(videoBox);//自己的视图往前添加 | 274 | + //自己的视图往前添加 |
| 275 | + $(this.localViewId).prepend(videoBox); | ||
| 266 | $("#"+viewName).css("transform", 'rotateY(180deg)'); | 276 | $("#"+viewName).css("transform", 'rotateY(180deg)'); |
| 267 | 277 | ||
| 278 | + //显示自己的名字 | ||
| 279 | + let user=GlobalConfig.getUserInfoFromeNodeId(this.uid); | ||
| 280 | + let userName=""; | ||
| 281 | + if(user){ | ||
| 282 | + userName=user.name||""; | ||
| 283 | + } | ||
| 284 | + let nameDiv=`<div id="${"videoOwnerName_"+this.uid}" style="width:98%;height:20px; position: absolute; z-index: 1;left: 4px;overflow:hidden;font-size: 14px; color: #cccccc;display:${this.nameDisplay}">${userName}</div>`; | ||
| 285 | + $(this.localViewId).prepend(nameDiv); | ||
| 268 | 286 | ||
| 269 | loger.log("webRtc->推流->",viewName,new Date().getTime()); | 287 | loger.log("webRtc->推流->",viewName,new Date().getTime()); |
| 270 | this.localStream.play(viewName); | 288 | this.localStream.play(viewName); |
| @@ -308,6 +326,7 @@ class WebRtcApe extends Emiter { | @@ -308,6 +326,7 @@ class WebRtcApe extends Emiter { | ||
| 308 | this.localStream.close(); | 326 | this.localStream.close(); |
| 309 | //$(this.localViewId).html(""); | 327 | //$(this.localViewId).html(""); |
| 310 | $('#localVideoBox_' + this.uid).remove(); | 328 | $('#localVideoBox_' + this.uid).remove(); |
| 329 | + $("videoOwnerName_"+this.uid).remove(); | ||
| 311 | 330 | ||
| 312 | this.isPublish=false; | 331 | this.isPublish=false; |
| 313 | GlobalConfig.openCamera =0; | 332 | GlobalConfig.openCamera =0; |
| @@ -331,6 +350,7 @@ class WebRtcApe extends Emiter { | @@ -331,6 +350,7 @@ class WebRtcApe extends Emiter { | ||
| 331 | this.localStyle = _params.styleStr||""; | 350 | this.localStyle = _params.styleStr||""; |
| 332 | this.localVideoWidth=parseInt(_params.width)||320; | 351 | this.localVideoWidth=parseInt(_params.width)||320; |
| 333 | this.localVideoHeight=parseInt(_params.height)||240; | 352 | this.localVideoHeight=parseInt(_params.height)||240; |
| 353 | + this.nameDisplay=_params.nameDisplay||"block"; | ||
| 334 | } | 354 | } |
| 335 | 355 | ||
| 336 | /* | 356 | /* |
-
请 注册 或 登录 后发表评论