What happened?
On Android, assigning muted=true more than once can overwrite the volume that should be restored when unmuting.
The first mute assignment stores the current player volume in userVolume and sets player.volume to 0. A second muted=true assignment then stores the current volume (0) in userVolume. When muted=false is assigned later, the player restores 0, so audio remains silent.
Expected behavior: repeated assignments of the same muted value should be a no-op, and unmuting should restore the volume from before muting.
The same application flow works as expected on iOS.
Adding the following guard to the Android muted setter preserves userVolume and restores audio correctly:
if (value == muted) return@mainThreadProperty
Steps to reproduce
A common setup is to assign the initial mute value when creating the player and synchronize the same React state in an effect:
const [muted, setMuted] = useState(true);
const player = useVideoPlayer(source, (player) => {
player.muted = muted;
});
useEffect(() => {
player.muted = muted;
}, [player, muted]);
On the initial render:
- The
useVideoPlayer setup callback assigns player.muted = true.
- The effect runs and assigns
player.muted = true again.
- Call
setMuted(false).
- Observe that playback remains silent.
The internal state changes as follows:
Initial state
player.volume = 1.0
userVolume = 1.0
Setup: muted=true
player.volume = 0.0
userVolume = 1.0
Effect: muted=true
player.volume = 0.0
userVolume = 0.0
setMuted(false)
player.volume = 0.0
The issue was reproduced without the guard. With the guard applied, unmuting restored speaker audio correctly on both tested Android devices.
Reproduction repository
No response
react-native-video version
7.0.0-beta.11
react-native version
0.81.5
react-native-nitro-modules version
0.35.0
Platforms
Android
OS version
Android 12 (Galaxy Fold 5G, SM-F907N) / Android 16 (Galaxy A33 5G, SM-A336N)
Device
Real device
Architecture
New Architecture
Expo
No (bare / React Native CLI)
Last working version
No response
Media / source type
No response
What happened?
On Android, assigning
muted=truemore than once can overwrite the volume that should be restored when unmuting.The first mute assignment stores the current player volume in
userVolumeand setsplayer.volumeto0. A secondmuted=trueassignment then stores the current volume (0) inuserVolume. Whenmuted=falseis assigned later, the player restores0, so audio remains silent.Expected behavior: repeated assignments of the same
mutedvalue should be a no-op, and unmuting should restore the volume from before muting.The same application flow works as expected on iOS.
Adding the following guard to the Android
mutedsetter preservesuserVolumeand restores audio correctly:Steps to reproduce
A common setup is to assign the initial mute value when creating the player and synchronize the same React state in an effect:
On the initial render:
useVideoPlayersetup callback assignsplayer.muted = true.player.muted = trueagain.setMuted(false).The internal state changes as follows:
The issue was reproduced without the guard. With the guard applied, unmuting restored speaker audio correctly on both tested Android devices.
Reproduction repository
No response
react-native-video version
7.0.0-beta.11
react-native version
0.81.5
react-native-nitro-modules version
0.35.0
Platforms
Android
OS version
Android 12 (Galaxy Fold 5G, SM-F907N) / Android 16 (Galaxy A33 5G, SM-A336N)
Device
Real device
Architecture
New Architecture
Expo
No (bare / React Native CLI)
Last working version
No response
Media / source type
No response