mp3 文件没有流式传输但是没有错误

mp3 file not streaming however no errors

这个文件不是作为 mp3 文件播放的,我不确定我的代码哪里搞砸了。打印 println 语句。

let urlString = "http://anything2mp3.com/system/files/mp3/Siberian%20Husky%20gets%20ICE%20POOL%20Extended_q1zY1dp1_ig_youtube.mp3"


@IBAction func tempPlay(sender: AnyObject) {

    println("runningtemp")
    let url = NSURL(string: urlString)
    var avPlayer = AVPlayer(URL: url)
    avPlayer.play()
}

您只需要从 IBAction 中声明您的 AVPlayer。

let urlString = "http://anything2mp3.com/system/files/mp3/Siberian%20Husky%20gets%20ICE%20POOL%20Extended_q1zY1dp1_ig_youtube.mp3"

var avPlayer:AVPlayer!

@IBAction func tempPlay(sender: AnyObject) {
    if let url = NSURL(string: urlString) {
        avPlayer = AVPlayer(URL: url)
        avPlayer.play()
    }
}