在我的应用中运行音频 按下音量调低键 降至1 1将不再下降。 我按调低音量键1 我想被静音。
我使用了Swift 4,iOS 11
在didFinishLaunchingWithOptions
中let session: AVAudioSession = AVAudioSession.sharedInstance()
do {
if #available(iOS 10.0, *) {
try session.setCategory(AVAudioSessionCategoryPlayAndRecord, mode: AVAudioSessionModeDefault, routeSharingPolicy: .longForm, options: [.defaultToSpeaker , .allowAirPlay ,.allowBluetooth ,.allowBluetoothA2DP])
try session.overrideOutputAudioPort(AVAudioSessionPortOverride.none)
} else {
session.perform(NSSelectorFromString("setCategory:withOptions:error:"), with: AVAudioSessionCategoryPlayAndRecord, with: [AVAudioSession.CategoryOptions.allowBluetooth,AVAudioSession.CategoryOptions.allowBluetoothA2DP,AVAudioSession.CategoryOptions.allowAirPlay])
}
try session.setActive(true)
} catch {
}
let commandCenter = MPRemoteCommandCenter.shared()
commandCenter.nextTrackCommand.isEnabled = false
commandCenter.previousTrackCommand.isEnabled = false
commandCenter.skipForwardCommand.isEnabled = false
commandCenter.skipBackwardCommand.isEnabled = false
当我按下降低音量键时,我希望音量完全关闭。 我的AVAudioSession是否有问题?