AVAudioPlayer无法使用swift 2.1听到任何声音

时间:2015-11-17 19:05:35

标签: ios iphone

我尝试让iOS应用播放一些有趣的声音,当我点击播放没有声音从扬声器输出这里是代码:

0x0ffffffff

没有错误,但我根本听不到任何声音

1 个答案:

答案 0 :(得分:0)

如何面对这个问题

@IBAction func slow(sender: UIButton) {
    if let path = NSBundle.mainBundle().pathForResource("io", ofType:"mp3") {

        let fileURL = NSURL(fileURLWithPath: path)
        player = try! AVAudioPlayer(contentsOfURL: fileURL)
        player.prepareToPlay()
        player.play()

    }
    else
    {

        print("error")
    }    
}
}