react-native-webrtc
react-native-webrtc copied to clipboard
MediaStreamTrack.muted flag should not be modified when `enabled` flag is changed
Expected behavior
MediaStreamTrack.muted property should not rely on MediaStreamTrack.enabled property.
Observerd behavior
Opposite to above - when toggling MediaStream.enabled flag, muted flag also gets toggled.
Steps to reproduce the problem
navigator.mediaDevices.getUserMedia({audio: true}).then(stream => {
console.log('--1:', JSON.stringify(stream.getAudioTracks()));
stream.getAudioTracks().forEach(track => track.enabled = false);
console.log('--2:', JSON.stringify(stream.getAudioTracks()));
stream.getAudioTracks().forEach(track => track.enabled = true);
console.log('--3:', JSON.stringify(stream.getAudioTracks()));
});
I see this output:
04-07 14:58:11.057 17736 17795 I ReactNativeJS: '--1:', '[{"_constraints":{},"_enabled":true,"id":"60751b32-53f5-45b3-bc56-de77c3732fda","kind":"audio","label":"60751b32-53f5-45b3-bc56-de77c3732fda","muted":false,"remote":false,"readyState":"live"}]'
04-07 14:58:11.059 17736 17795 I ReactNativeJS: '--2:', '[{"_constraints":{},"_enabled":false,"id":"60751b32-53f5-45b3-bc56-de77c3732fda","kind":"audio","label":"60751b32-53f5-45b3-bc56-de77c3732fda","muted":true,"remote":false,"readyState":"live"}]'
04-07 14:58:11.059 17736 17795 I ReactNativeJS: '--3:', '[{"_constraints":{},"_enabled":true,"id":"60751b32-53f5-45b3-bc56-de77c3732fda","kind":"audio","label":"60751b32-53f5-45b3-bc56-de77c3732fda","muted":false,"remote":false,"readyState":"live"}]'
But would assume muted property should not be changed as according to docs: https://developer.mozilla.org/en-US/docs/Web/API/MediaStreamTrack/muted it means device is somehow not able to produce audio. For simple "muting", enabled flag is used:
To implement a way for users to mute and unmute a track, use the enabled property. When a track is disabled by setting enabled to false, it generates only empty frames (audio frames in which every sample is 0, or video frames in which every pixel is black).
Platform information
- React Native version: 0.63.4
- Plugin version: 1.89.1
- OS: Android
- OS version: 10