isMute
Get Audio Mute State
isMute() is a synchronous query method in the SUDRTGameAudioSession interface. It is used to check whether the audio output of the current mini-game engine is set to muted. This state is a logical switch, independent of the device's physical volume buttons.
Method Declaration
java
/**
* Query whether the current game instance is muted.
* @return boolean Returns true if currently muted (silent); returns false if audio is output normally.
*/
boolean isMute();Runtime Behavior
- Logical State Feedback: This method reflects the logical state set via the SDK's
mute(boolean)method, not the value of the Android system media volume. - Immediate Response: This is a non-blocking lightweight method that reads the state bit directly from memory, and can be called frequently in a UI rendering loop or state-check logic.
- Scope: When it returns
true, all background music (BGM) and sound effects (SFX) within the game are suppressed, but it typically does not affect the App host layer's own audio playback.
Code Example
Sync the switch state when initializing the App's settings screen:
java
// Get the audio session control object
SUDRTGameAudioSession audioSession = mGameHandle.getAudioSession();
// Initialize the UI switch based on the game's internal mute state
boolean currentMuteStatus = audioSession.isMute();
muteSwitch.setChecked(currentMuteStatus);
Log.d("SudAudio", "Current game mute state: " + (currentMuteStatus ? "on" : "off"));Notes
- Hardware Switch Association: Under certain configurations, if
KEY_AUDIO_OBEY_MUTE_SWITCHis enabled, the physical mute key may affect this return result, depending on theAudioOptionsat initialization. - Default Value: Before
mute(true)is called, this method typically returnsfalseby default (i.e., sound on by default). - Difference from Volume Factor:
isMute()is a boolean switch, whilegetVolumeFactor()returns a specific volume ratio (0.0-1.0). Even if the volume factor is set to1.0, there will be no sound as long asisMute()istrue.
