Open putrafajarh opened 3 years ago
I want to create button to toggle audio off on, i need current status audio to show icon related to current status
isMuted(kind) { try { if (kind === 'audio') { const tracks = this.localStream.getAudioTracks() tracks.forEach(track => { console.log('track: ', track) }) // return this.localStream.getAudioTracks()[0].enabled return tracks[0].enabled } if (kind === 'video') { return this.localStream.getVideoTracks()[0].enabled } throw new Error('track kind is required') } catch (error) { console.error(error); } },
console.log('audio muted', this.isMuted('audio')) this.localStream.mute('audio') console.log('audio muted', this.isMuted('audio')) client.publish(this.localStream) this.localStream.unmute('audio') console.log('audio muted', this.isMuted('audio')) this.localStream.mute('audio') console.log('audio muted', this.isMuted('audio'))
MediaStreamTrack.enabled is false after localStream.mute('audio') MediaStreamTrack.enabled is true after localStream.unmute('audio')
MediaStreamTrack.enabled always true
Your environment.
What did you do?
I want to create button to toggle audio off on, i need current status audio to show icon related to current status
What did you expect?
MediaStreamTrack.enabled is false after localStream.mute('audio') MediaStreamTrack.enabled is true after localStream.unmute('audio')
What happened?
MediaStreamTrack.enabled always true