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
- Logical state sync: This method returns the logical switch value set via the
mute:method. - Priority independence: Even if
getVolumeFactorreturns1.0(maximum volume), ifisMutereturnsYES, the game still produces no sound. - 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,
isMutemay still returnNO(depending on whetherSUDRT_KEY_AUDIO_OBEY_MUTE_SWITCHis 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 typicallyNO(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_SWITCHconfiguration. - Usage recommendation: Before executing complex audio switching logic, first determine the state via
isMuteto avoid the performance overhead of redundantly callingmute:.
