How to handle audio stream in JsSIP?

扶醉桌前 提交于 2019-12-03 09:05:27

I solved the problem.

The problem was in the position of this.audioElement.play() line.

I moved it to the callback on addstream event:

this.state.callSession.connection.addEventListener('addstream', (event: any) => {
    console.log(event)
    this.audioElement.srcObject = event.stream
    this.audioElement.play()
})

Now it works fine. Hope you also find it useful.

You can use react-sip npm library which simplifies usage of jssip inside React apps: https://www.npmjs.com/package/react-sip

You will just need to pass your connection settings as props to <SipProvider/>, which will be somewhere near the top of your react tree. This will allow you to perform basic start/stop/answer operations and watch the status of your call in the context!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!