当声音开始时它不会停止, 我怎么能阻止它?
import AVFoundation
var audioPlayer2 = AVAudioPlayer()
var Sound2 = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("filename", ofType: "aiff")!)
override func viewDidLoad() {
super.viewDidLoad()
audioPlayer2 = AVAudioPlayer(contentsOfURL: Sound2, error: nil)
audioPlayer2.prepareToPlay() }
fund update() { ~ ~ ~ ~
audioPlayer2.play()
}
我试过
audioPlayer2.stop()
但它不起作用
答案 0 :(得分:0)
使用AVPlayer:
var player:AVPlayer!
var steamingURL:NSURL = NSURL(string:playerURL)
player = AVPlayer(URL: steamingURL)
player.play()