Adjust volume and mute

Learn how to control volume and mute state in the FastPix Android Player.

Set volume

Set the player volume on a scale from 0.0 (silent) to 1.0 (maximum). Values are clamped to this range.

1player.setVolume(0.75f) // Set volume to 75%
2val vol = player.getVolume() // Get current volume level

Mute and unmute

1player.mute() // Mute — stores the current volume for later restore
2player.unmute() // Unmute — restores the previous volume (defaults to 1.0)

mute() stores the current non-zero volume level. unmute() restores it, or defaults to 1.0 if no previous volume was saved.

Listen for volume changes

The SDK monitors system volume while at least one playback listener is attached. It fires callbacks for both programmatic and hardware button volume changes:

1override fun onVolumeChanged(volumeLevel: Float) {
2 // Device volume changed (0.0..1.0)
3}
4
5override fun onMuteStateChanged(isMuted: Boolean) {
6 // Mute state changed
7}

Use these callbacks to keep custom volume sliders and mute icons synchronized with the player’s audio state.