-2
我有下面显示的代码。它看起来很简单。但它没有播放任何音频。我该如何修改这个func用AVPlayer播放pls文件?
import AVFoundation
import MediaPlayer
func play(){
let player = AVPlayer(URL: NSURL(string: "http://www.liveatc.net/play/ltba.pls")!)
player.play()
}
您的代码表明你不理解的Swift中变量的生命周期。您可能需要阅读我的书:http://www.apeth.com/swiftBook/ch03.html#_variable_scope_and_lifetime – matt
thanks_________ @matt –