I am trying to reduce the data consumption of my app. Thats why I implemented the following caching for videos in my tableviewCells
https://stackoverflow.com/a/45062989/7186851
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
the cached video path looks something like this
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:///
When trying to play the video in the AVPlayer it won't work.
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)
}
}
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.
Any suggestions how to do it? I have a similar video feed to tiktok/instagram&fb if this helps.