Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


AudioSettings.Mobile

This class encapsulates properties and methods to handle audio output thread on iOS/Android.
Read time 2 minutesLast updated 7 days ago

Definition

  • Type: Class
  • Namespace: UnityEngine
  • Assembly: UnityEngine.AudioModule
public static class AudioSettings.Mobile

Remarks

You may be able to reduce the power consumption of your app or game by using this class. In general, for apps with simple looped music and short sound effects, you should set _stopAudioOutputOnMute to true, and also call AudioSettings.Mobile.StopAudioOutput if the user of your app sets music/sound volume to 0 in game settings. This helps to reduce power consumption on most mobile devices. Also you can check _muteState property and listen to AudioSettings.Mobile.OnMuteStateChanged event to stop/start audio output thread when required.
However, if your game or app has more complex sound or music logic, doing this could cause synchronization issues. In particular, any sounds playing when output is stopped are resumed from the same position when output is restarted, and so may be out of sync with any gameplay code that continued to run during that time. Therefore this setting may not be suitable if you are relying on gameplay elements that should be synchronized with parts of audio that may be continuing to play during output being switched off or on.

Static Properties

Property

Description

audioOutputStartedReturns true if audio output thread is working.
muteStateReturns true if current device media volume is 0.
stopAudioOutputOnMuteSet this property to true to make audio output thread automatically stop when device media volume is set to 0 and to start it again when volume is not 0.

Static Methods

Method

Description

StartAudioOutputStarts audio output thread on Android/iOS.
StopAudioOutputStops audio thread on Android/iOS.

Static Events

Member

Description

OnMuteStateChangedA delegate called whenever the device mute state is changed.