|
对讲功能,我开开发文档上面的demo是可以实现的,但是我按照demo些的代码,不行,只听到头盔发出“嘀”的一声,但是页面就上面没有图像和声音,浏览器控制台没有报错,我用的谷歌浏览器,请问,对讲有哪些需要注意的地方?相关代码如下:
this.session = new jSW.SWSession({
server: '127.0.0.1',
port: 9701,
onopen(sess: any) {
sess.swLogin({ user: `${credentials.username}`, password: `${credentials.password}` });
}
});
// 登录回调
this.session.swAddCallBack('login', (sender: any, event: any, json: any) => {
if (json.code === jSW.RcCode.RC_CODE_S_OK) {
} else {
this.logger.info(`账户或密码错误`);
}
});
// 获取设备列表回调
this.session.swAddCallBack('pulist', (sender: any, event: any, json: any) => {
if (json.code === jSW.RcCode.RC_CODE_S_OK) {
this.puList = this.session._arr_pu;
this.puList.forEach((item: any) => {
const random = Math.random();
item.random = random;
this.showdomList.push({ isHave: false, _id_pu: item._id_pu, domId: `dom${random}`, random })
});
console.log('this.puList:', this.puList);
}
});
const m_media = (jSW.MEDIADIR.AUDIOSEND) + (jSW.MEDIADIR.AUDIORECV);
const result = chanel.swOpenEx({
tag: this,
div: _this.getDomId(),
ismuti: true, // 设置可以被打开多次,
prototype: 'auto',
bovertcp: true,
media: m_media,
callback(options: any, response: any, event: any) {
const pthis = options.tag;
const code = response.emms.code;
if (code === 0) { // code === 0 成功
item.isOpen = true;
_this.addMediaToShowdomList(item, event.hdlg); // 唯一标识该路播放的句柄(关闭设备时需传入)
// 获取url
item.url = pthis.session.swGetPuChanel(`${item._id_pu}`, 0).swGetUrl();
_this.removeFlag();
} else if (code === 20106) {
_this.emptySpaceDomId();
_this.logger.info(`${item._name_pu} 未连接!`);
}
},
});
|
|