ionorg / ion-sdk-js

ion javascript sdk
MIT License
102 stars 70 forks source link

Audio MediaStreamTrack.enabled always true #212

Open putrafajarh opened 3 years ago

putrafajarh commented 3 years ago

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

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'))

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