title: Swift 5 play video from local cache
body: <p>I am trying to reduce the data consumption of my app. Thats why I implemented the following caching for videos in my tableviewCells</p>
  <p><a href="https://stackoverflow.com/a/45062989/7186851">https://stackoverflow.com/a/45062989/7186851</a></p>
  <p>It works so far, that I can check whether the video is in my cache or not but I am unable to play it from my local cache</p>
  <p>the cached video path looks something like this</p>
  <pre><code>file:/Users/Dev1/Library/Developer/CoreSimulator/Devices/86AFC4DE-CA7F-4AA4-97EE-0FB17173D5A4/data/Containers/Data/Application/697F3F33-A87A-4CDD-A1D0-D124A8CA5593/Library/Caches/-MV8TA8hReegG2OIUyy0 -- file:///
  </code></pre>
  <p>When trying to play the video in the AVPlayer it won't work.</p>
  <pre><code>            CacheManager.shared.getFileWith(stringUrl: vUrl) { result in
  
                  switch result {
                  case .success(let newUrl):
                      uri = URL(fileURLWithPath: newUrl.absoluteString)
                     // let url = URL(string: uri)
                      print(uri)
                      self.player = AVPlayer(url: uri)
                      self.playerLayer = AVPlayerLayer(player: self.player)
                      self.playerLayer?.frame = self.postImageView.frame
                      self.contentView.layer.addSublayer(self.playerLayer!)
                  case .failure(_):
                      uri = URL(string: vUrl)
                  }
              }
  </code></pre>
  <p>i start the video playing afterwards. It works perfectly fine when I download my videos from my cloudStorage, but I am unable to play the cached videos.</p>
  <p>Any suggestions how to do it?
  I have a similar video feed to tiktok/instagram&amp;fb if this helps.</p>