通过应用程序播放时,iOS应用程序的音频文件听起来比在应用程序外播放时要糟糕得多。这些声音看起来更苛刻,而且更多的是#eco;"。
这是我们播放音频的代码。我们是否以某种方式改变了音频的播放或自然声音?
我们使用的两个音频文件可以是found here:
private func createAudioPlayer(filename: String) -> AVAudioPlayer {
// Define file URL
let path = Bundle.main.path(forResource: filename, ofType: nil)
let url = URL(fileURLWithPath: path!)
// Create player
let audioPlayer: AVAudioPlayer!
do {
audioPlayer = try AVAudioPlayer(contentsOf: url)
} catch {
audioPlayer = nil
printError("Error creating audio player for \(url): \(error)")
logEvent("Audio Error", userData: nil)
}
// Print status
print("Created audio player for \(filename)")
// Return player
return audioPlayer
}
func play(file: AudioFileEnum) {
if let player = audioPlayers[file] {
if player.isPlaying {
player.pause()
}
player.currentTime = 0
player.play()
} else {
printError("Error finding audio player for \(file)")
}
}
答案 0 :(得分:1)
您是否尝试将audioPlayer对象上的音量设置为较小的值,如0.05f,并从那里进行调整?