为什么这个mp3文件不流式传输

时间:2015-06-08 01:57:05

标签: ios swift avfoundation

我试图使用`avPlayer`来播放这个mp3文件但是当我尝试播放时我只是沉默。我没有收到任何错误,这是我的代码

@IBAction func Test(sender: AnyObject) {
    println("Preparing to play")
    let urlString = "http://www.mp3juices.cc/get/3/194751031/x_ambassadors_-_renegades/"

    let url = NSURL(string: urlString)

    var avPlayer = AVPlayer(URL: url)
    avPlayer.play()
}

1 个答案:

答案 0 :(得分:0)

import AVFoundation

class ViewController: UIViewController {

    // declare your avPlayer here
    var avPlayer: AVPlayer!

    override func viewDidLoad() {
        super.viewDidLoad()
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }

    @IBAction func test(sender: AnyObject) {
        println("Preparing to play")
        let url = NSURL(string: "http://www.mp3juices.cc/get/3/194751031/x_ambassadors_-_renegades/")
        avPlayer = AVPlayer(URL: url)
        avPlayer.play()
    }
}