2017-06-13 53 views
0

iOS應用程序的音頻文件在應用程序中播放時聽起來比在應用程序外播放時糟糕得多。這些聲音看起來更加粗糙,更加「ecohy」。iOS:應用程序聲音中使用的音頻文件比在應用程序外播放時要嚴格

這是我們播放音頻的代碼。我們是否改變了音頻的播放或自然聲音?

我們使用可以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

如何以及在哪裏在應用程序之外播放文件? – hotpaw2

+0

@ hotpaw2就像在桌面上一樣。有什麼建議麼? – Crashalot

+0

您的桌面系統可能使用與iPhone不同的音頻音量,DAC,放大器和揚聲器。 – hotpaw2

回答

1

你有沒有試過audioPlayer對象上設置音量小東西,像0.05f,並從那裏調整?

+0

試試吧,感謝您的建議 – Crashalot

相關問題