gpt4 book ai didi

ios - 启用/禁用背景音乐

转载 作者:可可西里 更新时间:2023-11-01 02:18:05 25 4
gpt4 key购买 nike

要从应用程序 Spotify 或音乐应用程序启用背景音乐,我使用以下代码:

do
{
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryAmbient)
try AVAudioSession.sharedInstance().setActive(true)
}
catch let error as NSError
{
print(error)
}

但是我怎样才能扭转这种局面,停止播放背景音乐呢?

最佳答案

根据 the documentation ,主要的播放 Audio Session 类别是:

AVAudioSessionCategoryAmbient

Whenyou use this category, audio from other apps mixes with your audio.

AVAudioSessionCategorySoloAmbient

By default, using this category implies that your app’s audio isnonmixable—activating your session will interrupt any other audiosessions which are also nonmixable.

AVAudioSessionCategoryPlayback

By default, using this category implies that your app’s audio isnonmixable—activating your session will interrupt any other audiosessions which are also nonmixable.

因此,您特意选择了播放类别,不会使不可混合的背景音频静音。如果您确实想要将不可混音的背景音频静音,请选择其他类别之一。随时更改类别没有错。

关于ios - 启用/禁用背景音乐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34793076/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com