如何在本地保存流媒体视频?
我使用以下代码使用AVPlayer播放m3u8文件。
private func playVideo3() {
guard let url = URL(string: "http://filenaname.m3u8") else {
return
}
// Create an AVPlayer, passing it the HTTP Live Streaming URL.
let player = AVPlayer(url: url)
let playerLayer = AVPlayerLayer(player: player)
playerLayer.frame = view3.bounds
playerLayer.backgroundColor = UIColor.purple.cgColor
view3.layer.addSublayer(playerLayer)
player.play()
}
按下停止按钮(自定义按钮)时,我需要将流式视频保存到PhotoLibrary中。
答案 0 :(得分:0)
您可以尝试使用NSURLProtocol Subclassing并保存视频。
https://www.raywenderlich.com/76735/using-nsurlprotocol-swift