使用webRTC推流

使用腾讯实时音视频模块进行音视频通讯

 

 

前提:需要重新打包设置打包标识,并设置sdkappid和secretkey

 

一.直接调用

 

1.检查权限

 

1)添加检查权限元素,如下图所示:

 

 

 

 

2)添加同步数据元素,返回调用获取权限的函数:$.wwclass.callApp("TRTC",{"method":"checkpermission"},function(data){console.log(data)})  ;返回结果如下图所示:

 

 

 

2.调用音视频通讯插件

 

1)在需要设置视频通话按钮位置右键,选择逻辑设置-->逻辑-->附加逻辑控制操作详细信息-->提交数据-->高级编辑填写视口信息-->添加操作:

 

 

2)视口,返回直接调用腾讯音视频的函数:$.wwclass.callApp("trtc",{"roomid":"数字","userid":"任意值","usersig":"不使用官方文档生成就给空值","roomtype":"audio为语音,video为视频","guestimage":"通话时对方的头像,需要图片完整地址如:http://a.com/b/c.jpg,域名与app保持一致","guestname":"通话时对方的昵称","totaltime":"预约的分钟数"},function(data){console.log(data)}) ;如下图所示:

 

注意:参数中roomid必须为数字,腾讯官方是作为整数处理的roomid这里的数字不能大于整数的上限(-2147483648——2147483647)

 

 

 

 

 

 

二.使用 腾讯实时音视频元素

 

注释:一进页面就自动跳转至腾讯云音视频

 

1.添加腾讯实时音视频元素和检查权限元素

 

 

 

 

2.在腾讯实时音视频元素上进行属性绑定和绑定变量初始化,绑定参数:{"data-trtcroomid":roomid,"data-trtcuserid":userid,"data-trtcusersig":usersig,"data-trtcroomtype":roomtype,"data-trtcguestimage":guestimage,"data-trtcguestname":guestname,"data-trtctotaltime":totaltime} ,绑定变量初始化:{"roomid":123456,"userid":110,"usersig":"","roomtype":"video","guestimage":"https://tiyan.wware.org/img/a2.png","guestname":120,"totaltime":30}

 

注意:roomid,腾讯官方是作为整数处理的roomid这里的数字不能大于整数的上限(-2147483648——2147483647)

 

腾讯实时音视频元素案例:

 

 <div class="lyrow ui-draggable" data-layer="data"><a href="#close" class="remove label label-danger"><i class="glyphicon-remove glyphicon"></i>删除</a> <span class="drag label label-default ui-draggable-handle"><i class="glyphicon glyphicon-move"></i> 拖拽</span> <span class="configuration"><button class="label label-warning" type="button" data-target="#editorModal" data-toggle="modal" data-backdrop="false" data-keyboard="false" data-type="layout"><span><i class="glyphicon glyphicon-edit"></i></span>编辑</button><span class="layername">data</span></span><div class="preview"><input class="form-control" value="12"></div><div class="view"><div class="row clearfix"><div class="col-md-12 column ui-sortable"><div class="box box-element ui-draggable ui-sortable-handle"><a href="#close" class="remove label label-danger"><i class="glyphicon glyphicon-remove"></i> 删除</a><span class="drag label label-default ui-draggable-handle"><i class="glyphicon glyphicon-move"></i> 拖拽</span> <span class="configuration"><button type="button" class="label label-default" data-target="#editorModal" data-toggle="modal"><span><i class="glyphicon glyphicon-edit"></i></span>编辑</button></span><div class="preview"></div><div class="view"><div data-permission="[&quot;CAMERA&quot;,&quot;RECORD_AUDIO&quot;]" data-removetitle="" data-wwclass="permission" data-wwcompiler="http://www.wware.org/db/templates/d9/f3/7740/58f5/3421/5e14/8743/76c3/cb38/public/compiler/permission.js" data-wweditor="http://www.wware.org/db/templates/d9/f3/7740/58f5/3421/5e14/8743/76c3/cb38/public/editor/permission.js" data-wwlabel="权限检查元素" data-wwplugin="http://www.wware.org/db/templates/d9/f3/7740/58f5/3421/5e14/8743/76c3/cb38/public/runtime/" title="权限检查元素, 用于Android新权限检查机制, 可右键调进行元素设置">权限检查</div>
</div></div><div class="box box-element ui-draggable ui-sortable-handle"><a href="#close" class="remove label label-danger"><i class="glyphicon glyphicon-remove"></i> 删除</a><span class="drag label label-default ui-draggable-handle"><i class="glyphicon glyphicon-move"></i> 拖拽</span> <span class="configuration"><button type="button" class="label label-default" data-target="#editorModal" data-toggle="modal"><span><i class="glyphicon glyphicon-edit"></i></span>编辑</button></span><div class="preview"></div><div class="view">

<p>&nbsp;</p>

<div data-bind="attr: {&quot;data-trtcroomid&quot;:roomid,&quot;data-trtcuserid&quot;:userid,&quot;data-trtcusersig&quot;:usersig,&quot;data-trtcroomtype&quot;:roomtype,&quot;data-trtcguestimage&quot;:guestimage,&quot;data-trtcguestname&quot;:guestname,&quot;data-trtctotaltime&quot;:totaltime}" data-bindvars="{&quot;roomid&quot;:123456,&quot;userid&quot;:110,&quot;usersig&quot;:&quot;&quot;,&quot;roomtype&quot;:&quot;video&quot;,&quot;guestimage&quot;:&quot;https://tiyan.wware.org/img/a2.png&quot;,&quot;guestname&quot;:120,&quot;totaltime&quot;:30}" data-removetitle="" data-wwclass="wwaretrtc" data-wwcompiler="http://www.wware.org/db/templates/dc/3c/d92b/3a2e/ed2c/8c74/3a0e/aa61/a86e/public/compiler/wwaretrtc.js" data-wweditor="http://www.wware.org/db/templates/dc/3c/d92b/3a2e/ed2c/8c74/3a0e/aa61/a86e/public/editor/wwaretrtc.js" data-wwlabel="腾讯实时音视频元素" data-wwplugin="http://www.wware.org/db/templates/dc/3c/d92b/3a2e/ed2c/8c74/3a0e/aa61/a86e/public/runtime/" title="腾讯实时音视频元素, 用于视频语音通话, 可右键调进行元素设置">腾讯实时音视频元素</div>

</div></div></div></div></div></div><script id="_wwblockConfig" data-config="%7B%22noscale%22:false,%22showwhen%22:%22always%22,%22wwdebug%22:%22none%22,%22preload%22:%5B%5D,%22title%22:%22%E8%85%BE%E8%AE%AF%E4%BA%91%E9%9F%B3%E8%A7%86%E9%A2%91%E5%85%83%E7%B4%A0%E6%B5%8B%E8%AF%95%22%7D"></script>