菜鸟教程小白 发表于 2022-12-12 15:40:25

ios - 禁用 AVAudioSession 后 Unity 声音不起作用


                                            <p><p>我目前正在开发 Unity3D iOS 插件。我正在尝试更改应用程序的 AVAudioSession 的类别以实现音频闪避(即音乐应用程序音量在我的音效播放时降低),这需要将 AVAudioSession 设置为非事件状态,然后再次设置为事件状态。</p>

<p>好吧,在我使用 <code>[ setActive:NO er​​ror:nil]</code> 将 session 设置为非事件状态后,Unity 声音将不再起作用,即使 session 设置为再次活跃。原生声音仍然有效,因为我测试了一个 AVAudioPlayer,它运行良好。</p>

<p>有什么问题吗?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>用户 <a href="http://answers.unity3d.com/users/603021/daniel-liu-1.html" rel="noreferrer noopener nofollow">daniel_liu</a>来自 Unity 问答 <a href="http://answers.unity3d.com/questions/995956/unity-sounds-not-playing-after-avaudiosession-is-d.html#answer-1021921" rel="noreferrer noopener nofollow">helped me with this</a> :不要使用我在问题中发布的代码将 AVAudioSession 设置为事件/非事件,而应该使用 <code>UnitySetAudioSessionActive(true)</code> 和 <code>UnitySetAudioSessionActive(false)</code>。</p ></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 禁用 AVAudioSession 后 Unity 声音不起作用,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/31102160/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/31102160/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 禁用 AVAudioSession 后 Unity 声音不起作用