wxxsw / GSPlayer

⏯ Video player, support for caching, preload, fullscreen transition and custom control view. 视频播放器,支持边下边播、预加载、全屏转场和自定义控制层
MIT License
422 stars 100 forks source link

Is there a way to cache a local file with a specified path? #79

Open Ruddch opened 1 year ago

Ruddch commented 1 year ago

I would like to have a similar capability, but due to the privacy of the methods, it is not possible.


static func cacheVideo(
      localURL: URL,
      remoteURL: URL
    ) async {      
      guard let data = try? Data(contentsOf: localURL) else { return }
      let fileManager = FileManager.default
      let filePath = VideoCacheManager.cachedFilePath(for: remoteURL)
      do {
        try fileManager.copyItem(atPath: localURL.path, toPath: filePath)
        let config = try VideoCacheManager.cachedConfiguration(for: remoteURL)
        config.add(fragment: 0..<data.count)
        config.save()
      } catch {
        print(error)
      }
}