gpt4 book ai didi

xcode - 使用物理静音 iPhone 按钮静音 AVFoundation 声音

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

我已经使用 AVFoundation 向我的游戏添加了声音并且它运行良好,除了在设置静音开和关(使用 iPhone 的物理静音按钮)时声音播放。当静音按钮打开时,如何让我的应用静音?这是我正在使用的代码:

import AVFoundation

var audioPlayerMenu = AVAudioPlayer()
var selectSound = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("select", ofType: "mp3")!)

audioPlayerMenu = AVAudioPlayer(contentsOfURL: selectSound, error: nil)
audioPlayerMenu.prepareToPlay()
audioPlayerMenu.play()

最佳答案

你不能使用 AVFoundation 做到这一点,我建议允许用户在你的应用程序中选择静音。我见过的几乎每个应用程序都是这样做的

关于xcode - 使用物理静音 iPhone 按钮静音 AVFoundation 声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26113242/

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