I try to play video from locally saved video. I got files as data and I can’t handle it to play this data. Should I chance the something on the code or how can I do?
Here is my code :
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
self.dismiss(animated: true, completion: nil)
videoURL = info[UIImagePickerController.InfoKey.init(rawValue: "UIImagePickerControllerMediaURL")] as? URL
let nameOfYourFile = "StoredVideos"
do {
guard let folderURL = URL.createFolder(folderName: nameOfYourFile) else {
print("Can't create url")
return
}
let permanentFileURL = folderURL.appendingPathComponent(nameOfYourFile).appendingPathExtension("MOV")
let videoData = try Data(contentsOf: videoURL!)
try videoData.write(to: permanentFileURL, options: .atomic)
print(folderURL)
let input = try Data(contentsOf: permanentFileURL)
print(input)
//...
} catch {
//
}
}