[英]How to save streaming video in iOS?
How to save a streaming video locally? 如何在本地保存流视频?
I am using the below code using AVPlayer for playing a m3u8 file. 我正在使用下面的代码通过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()
}
I need to save the streaming video into PhotoLibrary when pressing on the stop button(custom Button). 按下停止按钮(自定义按钮)时,我需要将流视频保存到PhotoLibrary中。
you can try with NSURLProtocol Subclassing and save the video. 您可以尝试使用NSURLProtocol子类化并保存视频。
https://www.raywenderlich.com/76735/using-nsurlprotocol-swift https://www.raywenderlich.com/76735/using-nsurlprotocol-swift
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.