Play video from core data

in swift UIKit I have a video from my camera roll

I store it in core data But when I restore it and when I try to turn it on, it doesn't work

Is my idea correct? I can store and display the video

use PHPickerViewController


result.itemProvider.loadFileRepresentation(forTypeIdentifier: UTType.movie.identifier) { url, err in

                do {

                    if let urls = url {

                        

                        let localURL = FileManager.default.temporaryDirectory.appendingPathComponent(urls.lastPathComponent)

                        try? FileManager.default.removeItem(at: localURL)

                        try FileManager.default.copyItem(at: urls, to: localURL)

                        DispatchQueue.main.sync {

                            

                            coreDateHelperMedia().storeMedia(urlImg: UIImage.init(), videoURL: localURL, types: "video")

                            self.collection.reloadData()

                        }

                    }

                } catch let error {

                    print("Error",error)

                }

            }

Here I present it

let dataUrl = arrS1[indexPath.row]

                let urlvideo = dataUrl.videoSection?.absoluteString

                

                guard let url = URL(string: urlvideo!) else {return}

                let player = AVPlayer(url: URL(fileURLWithPath:url.path))

                playerController = AVPlayerViewController()

                playerController.player = player

                playerController.allowsPictureInPicturePlayback = true

                playerController.delegate = self

                present(playerController, animated: true) {

                    player.play()

I've been sitting for a week and I'm doing everything I can, but I don't understand what's wrong

Although without data storage, it works fine

Play video from core data
 
 
Q