我从 mp3 网站播放歌曲,但是我需要预加载歌曲,以便当我运行 player.play() 时,歌曲将立即开始,没有缓冲,并且希望不会在整首歌曲中缓冲。有没有办法实现此目的,或者文件必须存储在本地?
override func viewDidLoad() {
super.viewDidLoad()
appDelegate = UIApplication.sharedApplication().delegate as? AppDelegate
println(test_)
timer = NSTimer.scheduledTimerWithTimeInterval(0.02, target: self, selector: "saveTime", userInfo: nil, repeats: true)
appDelegate.mpcHandler.sendSongInfo()
NPMusicClient.sharedClient().urlForSongWithQuery("\(artistName_) \(title_)", success: { (url) -> Void in
AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback, error: nil)
AVAudioSession.sharedInstance().setActive(true, error: nil)
self.player = AVPlayer(URL: url)
self.player.play()
}) { (message) -> Void in
println(message)
}
startplaying()
// Do any additional setup after loading the view.
println(boolValue)
functionLevel()
}
最佳答案
嘿,大家好,我自己找到了问题的答案,简单地说,如果其他人正在考虑实现此目的,只需将播放器静音,因为歌曲在播放时会缓冲,然后返回 0:00
关于ios - 如何预加载来自 Web 链接的 mp3 流,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32160627/