简体   繁体   中英

Unity sound not working after AVAudioSession is disabled

I'm currently working on a Unity3D iOS plugin. I'm trying to change the category of the app's AVAudioSession in order to implement audio ducking (ie Music app volume goes down while my sound effects are playing), which requires the AVAudioSession to be set as inactive and then as active again.

Well, after I set the session as inactive by using [[AVAudioSession sharedInstance] setActive:NO error:nil] , Unity sounds simply won't work anymore, even after the session is set as active again. Native sounds still work, as I tested an AVAudioPlayer and it works perfectly.

Any idea on what's wrong?

来自 Unity Answers 的用户daniel_liu 帮助我解决了这个问题:不是使用我在问题中发布的代码将 AVAudioSession 设置为活动/非活动,而是应该使用UnitySetAudioSessionActive(true)UnitySetAudioSessionActive(false)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM