我正在尝试播放声音,AVAudioPlayer但无法正常工作。编辑1:仍然行不通。编辑2:此代码有效。我的设备处于静音模式。import UIKitimport AVFoundationclass ViewController: UIViewController { var audioPlayer = AVAudioPlayer() override func viewDidLoad() { super.viewDidLoad() var alertSound = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("button-09", ofType: "wav")) println(alertSound) var error:NSError? audioPlayer = AVAudioPlayer(contentsOfURL: alertSound, error: &error) audioPlayer.prepareToPlay() audioPlayer.play() }}
3 回答
- 3 回答
- 0 关注
- 1160 浏览
添加回答
举报
0/150
提交
取消