【问题标题】:How to playback an audio file with TheAmazingAudioEngine with Swift?如何使用 Swift 使用 TheAmazingAudioEngine 播放音频文件?
【发布时间】:2015-12-24 14:01:18
【问题描述】:

我需要使用 TheAmazingAudioEngine frameworkSwift 播放单个音频文件。 我完全是这个框架的新手,并尝试了下面的代码,但音频没有播放。怎么了?如何播放音频文件?

do {
    var audioController = AEAudioController(audioDescription: AEAudioController.nonInterleavedFloatStereoAudioDescription())
    let file = NSBundle.mainBundle().URLForResource("myaudiofile", withExtension: "wav")!
    let channel = try AEAudioFilePlayer(URL: file)
    audioController?.addChannels([channel])
    channel.playAtTime(0)
} catch {
    print("Failure")
}

【问题讨论】:

    标签: ios swift audio the-amazing-audio-engine


    【解决方案1】:

    我错过了启动audioController

    do {
        var audioController = AEAudioController(audioDescription: AEAudioController.nonInterleavedFloatStereoAudioDescription())
        let file = NSBundle.mainBundle().URLForResource("myaudiofile", withExtension: "wav")!
        let channel = try AEAudioFilePlayer(URL: file)
        audioController?.addChannels([channel])
        try audioController!.start()
    } catch {
        print("Failure")
    }
    

    【讨论】:

      猜你喜欢
      • 2017-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-10-07
      • 1970-01-01
      • 2015-07-28
      相关资源
      最近更新 更多