Skip to content

isMute ​

Query Mute State ​

isMute is a synchronous query method of the SUDRTGameAudioSession protocol. It is used to obtain the current game engine's software mute state. This state reflects whether the App has disabled game audio output through the SDK interface; it does not represent the state of the iOS system's hardware mute switch.


Method Declaration ​

objc
/**
 * Queries whether the current game audio is muted.
 * @return YES indicates muted, NO indicates playing.
 */
- (BOOL)isMute;

Runtime Behavior ​

  1. Logical state sync: This method returns the logical switch value set via the mute: method.
  2. Priority independence: Even if getVolumeFactor returns 1.0 (maximum volume), if isMute returns YES, the game still produces no sound.
  3. Software-hardware isolation: This method reports only the SDK's internal mute flag. If the user toggles the physical mute switch on the side of the iPhone, isMute may still return NO (depending on whether SUDRT_KEY_AUDIO_OBEY_MUTE_SWITCH is configured in the audio options).

Code Example ​

Used to sync the state of a mute button in the App UI:

objc
- (void)updateMuteButtonState {
    // 1. Get the current mute state of the SDK
    BOOL muted = [self.audioSession isMute];
    
    // 2. Switch the icon based on the state (for example: speaker icon vs. muted icon)
    UIImage *icon = muted ? [UIImage imageNamed:@"icon_audio_off"] : [UIImage imageNamed:@"icon_audio_on"];
    [self.muteButton setImage:icon forState:UIControlStateNormal];
    
    NSLog(@"Current game mute state: %@", muted ? @"Muted" : @"Playing");
}

Notes ​

  • Initial state: Before mute: is called, the SDK's default state is typically NO (not muted).
  • Difference from system mute: App developers should distinguish between "App business mute" and "system hardware mute". If you need to ensure the game follows the system mute switch under all circumstances, consult the SUDRT_KEY_AUDIO_OBEY_MUTE_SWITCH configuration.
  • Usage recommendation: Before executing complex audio switching logic, first determine the state via isMute to avoid the performance overhead of redundantly calling mute:.