AV基金会过渡音乐停止

时间:2015-12-29 05:05:42

标签: xcode swift sprite-kit

我正在使用以下代码播放音乐。它发挥得很好:))

 var backgroundMusicPlayer = AVAudioPlayer()

    func playBackgroundMusic(filename: String) {
        let url = NSBundle.mainBundle().URLForResource(filename, withExtension: nil)
        guard let newURL = url else {
            print("Could not find file: \(filename)")
            return
        }
        do {
            backgroundMusicPlayer = try AVAudioPlayer(contentsOfURL: newURL)
            backgroundMusicPlayer.numberOfLoops = -1
            backgroundMusicPlayer.prepareToPlay()
            backgroundMusicPlayer.play()
        } catch let error as NSError {
            print(error.description)
        }
    }

 playBackgroundMusic("music.wav")

但是,我希望能够通过某些过渡来保持音乐播放。这可能吗?

干杯:)

0 个答案:

没有答案