我正在使用Alamofire
进行联网并使用Swift 4
。
我需要从网址下载视频并将其存储在特定位置,然后使用UIActivityViewController
,Facebook
,Messages
等上的Twitter
进行分享。
有人可以提供一些示例代码或指导我吗?
此致!!
答案 0 :(得分:1)
尝试使用Alamofire下载视频
func downloadVideo() {
let destination = DownloadRequest.suggestedDownloadDestination()
let url = "https://lynda_files2-a.akamaihd.net/secure/courses/391599/VBR_MP4h264_main_SD/391599_00_01_WX30_welcome.mp4?c3.ri=3770828196132302975&hashval=1522966719_0c357049da0562665ab3f99ccd3e8bca"
Alamofire.download(url, to: destination).downloadProgress(queue: DispatchQueue.global(qos: .utility)) { (progress) in
print("Progress: \(progress.fractionCompleted)")
} .validate().responseData { [weak self] (response) in
self?.shareVideo(from: response.destinationURL!)
}
}
并使用UIActivityViewController进行分享
func shareVideo(from url: URL) {
let activityViewController = UIActivityViewController(activityItems: [url], applicationActivities: nil)
present(activityViewController, animated: true, completion: nil)
}