假设我有一个简单的控制器,如下所示:
import Foundation
import UIKit
import AVKit
class AVQueuePlayerController:UIViewController{
private let player:AVQueuePlayer = AVQueuePlayer()
private let playerController = AVPlayerViewController()
let playerItems:[String] = [
"http://someurl.com/myvideo1.m4v",
"http://someurl.com/myvideo2.m4v",
"http://someurl.com/myvideo1.m4v"
]
override func viewDidLoad() {
super.viewDidLoad()
self.playerItems.forEach { (item) in
player.insert(createPlayerItem(item), after: nil)
}
playerController.player = player
self.present(playerController, animated: true)
player.play()
}
private func createPlayerItem(_ url:String)->AVPlayerItem{
return AVPlayerItem.init(url: URL.init(string: url)!)
}
}
它将通过第一段和第二段视频。到达具有相同URL的第三个时,会再次加载它还是将视频保存在内存中以避免再次下载?
如果不是这种情况,是否可以将其保存在内存中?最终目的是节省带宽
感谢您的时间