0
當聲音開始它不會停止, 我該如何阻止它?iOS Swift;停止AVFoundation重複
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()
,但它不工作