js-audio-talk
v1.3.0
Published
js voice real-time intercom
Downloads
58
Readme
js-audio-talk
npm 或 yarn 安装
yarn add js-audio-talk
引用
import { Talker } from 'js-audio-talk'
const startButton = document.getElementById('start')
const stopButton = document.getElementById('stop')
let talker= null
startButton.onclick = () => {
talker = new Talker({socketUrl: 'ws://192.168.1.108:40001/talk'})
talker.start().then(successCb).catch(errorCb)
//用于监听网络连接错误
talker.on("socketErr", (arg1, arg2) => {
console.log("socketErr", arg1, arg2)
})
//用于监听是否开启摄像头、麦克风权限
talker.on("isHasPermission", (arg1, arg2) => {
console.log("isHasPermission", arg1, arg2)
})
}
stopButton.onclick = () => {
talker.stop().then(successCb).catch(errorCb)
}
注意
通过 MediaDevices.getUserMedia() 获取用户多媒体权限时,需要注意其只工作于以下三种环境:
localhost 域
开启了 HTTPS 的域
使用 file:/// 协议打开的本地文件
http环境下解决方法