接口说明
以下介绍cmsv6player.min.js插件进行广播的API接口。
使用前需要加载插件,参见:初始化插件
https可以直接广播;http广播时,需要下载安装PCM音频采集工具。
音频采集工具下载链接: https://v7.cmsv8.com/product/CMSV6PcmTool/CMSV6PcmTool.exe
开始广播
startBroadcast(jsession, lstDevIdnos, channel)
//全局设置过setServerInfo的,serverIp和serverPort可以不填
| 参数名称 |
参数类型 |
必须 |
示例 |
参数含义 |
| jsession |
string |
是 |
66d754dd7f41473dbd2 |
用户登录返回的会话号 |
| lstDevIdnos |
string |
是 |
013800000001,013800000002 |
设备号,多个设备号使用逗号分割 |
| channel |
number |
是 |
0 |
通道号,传0 |
停止广播
// 停止广播
stopBroadcast()
广播回调事件
| 参数名称 |
参数含义 |
| showDownLoadDialog |
需要下载PCM音频采集工具 |
| startBroadcast |
开始广播 |
| broadcasting |
广播中 |
| stopBroadcast |
停止广播 |
| requireBroadcast |
请求广播中 |
示例代码
//设置广播参数
cmsv6player.setTalkParam(1);
cmsv6player.setTalkMaxParam(2);
//启动广播
//通过 onTtxVideoMsg 消息回调来判断 type=broadcasting表示正在广播中,type=showDownLoadDialog表示需要下载pcm采集工具
cmsv6player.startBroadcast("66d754dd7f41473dbd2", "013800000001,013800000002", 0, 127.0.0.1, 6605)
//停止广播
cmsv6player.stopBroadcast();
//广播事件
function onTtxVideoMsg(index,type) {
if(type == "showDownLoadDialog"){
//需要下载PCM音频采集工具,非https时使用
} else if(type == "broadcasting"){
//广播中
} else if(type == "startBroadcast"){
//开始广播
} else if (type == "requireBroadcast") {
//请求广播中
} else if (type == "stopBroadcast ") {
//停止广播
}
}