我尝试了这个:
我把这段代码放在
提前感谢!
let soundFilePath = NSBundle.mainBundle().pathForResource("GL006_SNES_Victory_loop.aif", ofType: "GL006_SNES_Victory_loop.aif")
let soundFileURL = NSURL(fileURLWithPath: soundFilePath!)
let player = AVAudioPlayer(contentsOfURL: soundFileURL, fileTypeHint: nil)
player.numberOfLoops = -1 //infinite
player.play()
我把这段代码放在
didMoveToView
函数中,在我的代码顶部导入了import AVFoundation
。我得到了错误:Call can throw, but it is not marked with 'try' and the error is not handled
。提前感谢!
fatal error: unexpectedly found nil while unwrapping an Optional value (lldb)
,它说soundFilePath!
是nil
。 - Raxzon