此类封装的属性和方法用于处理 iOS/Android 上的音频输出线程。
使用此类可降低应用程序或游戏的功耗。通常,对于单曲
循环音乐和短音效,应将 AudioSettings.Mobile.stopAudioOutputOnMute 设置为 true,另外,如果应用程序的用户在游戏设置中将音乐/声音音量设置为 0,还应调用
AudioSettings.Mobile.StopAudioOutput。这样有助于减少
大多数移动设备的功耗。此外,还可以检查 AudioSettings.Mobile.muteState 属性和侦听
AudioSettings.Mobile.OnMuteStateChanged 事件以在需要时停止/开始音频输出线程。
但是,如果游戏或应用程序有更复杂的声音或音乐逻辑,这样可能会导致同步问题。具体而言,当输出停止时播放的声音
是从输出重新启动时的相同位置恢复的,因此,可能与在该段时间内继续
运行的任何游戏代码不同步。因此,如果要依赖于应与音频的组成部分同步,而在输出关闭或开启过程中
会继续播放的游戏元素,则不适合使用此设置。
audioOutputStarted | 如果音频输出线程在运行,则返回 true。 |
muteState | 如果当前设备媒体音量为 0,则返回 true。 |
stopAudioOutputOnMute | 如果将此属性设置为 true,则音频输出线程会在设备媒体音量设置为 0 时自动停止,在音量不为 0 时再次启动。 |
StartAudioOutput | 在 Android/iOS 上启动音频输出线程。 |
StopAudioOutput | 在 Android/iOS 上停止音频线程。 |
OnMuteStateChanged | 每当设备静音状态发生变化时调用的委托。 |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.