I have my song playing from an mp3 website however I need to preload the song so that when I run player.play(), the song will start immediately with no buffering and also hopefully not buffer throughout the whole song. Is there a way to accomplish this or would the file have to be stored locally?
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()
}
Aucun commentaire:
Enregistrer un commentaire