我想知道我如何才能永远重放我的背景音乐,现在当应用程序加载音乐开始,但当它结束时一切都是安静的,我如何才能使它重放所有的时间。
我正在使用AVFoundation Framework
。
宣言:
var BackgroundMusic = AVAudioPlayer(contentsOfURL: NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource("De_Hofnar_Zonnestraal", ofType: "mp3")!), error: nil)
内部
viewDidLoad
:BackgroundMusic.play()
最佳答案
将numberOfLoops
属性设置为负值。
backgroundMusic.numberOfLoops = -1
backgroundMusic.play() // To stop, call stop()