Fix(ios): another video caching fix (#3348)

* fix: another fix from video caching

---------

Co-authored-by: olivier <olivier.bouillet@ifeelsmart.com>
This commit is contained in:
Olivier Bouillet 2023-11-16 22:13:53 +01:00 committed by GitHub
parent fdbd6a6ba8
commit 8777b0a35e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 7 deletions

View File

@ -80,7 +80,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
private var _resouceLoaderDelegate: RCTResourceLoaderDelegate? private var _resouceLoaderDelegate: RCTResourceLoaderDelegate?
private var _playerObserver: RCTPlayerObserver = RCTPlayerObserver() private var _playerObserver: RCTPlayerObserver = RCTPlayerObserver()
#if canImport(RCTVideoCache) #if USE_VIDEO_CACHING
private let _videoCache:RCTVideoCachingHandler = RCTVideoCachingHandler() private let _videoCache:RCTVideoCachingHandler = RCTVideoCachingHandler()
#endif #endif
@ -174,7 +174,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
object: nil object: nil
) )
_playerObserver._handlers = self _playerObserver._handlers = self
#if canImport(RCTVideoCache) #if USE_VIDEO_CACHING
_videoCache.playerItemPrepareText = playerItemPrepareText _videoCache.playerItemPrepareText = playerItemPrepareText
#endif #endif
} }
@ -316,7 +316,7 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
throw NSError(domain: "", code: 0, userInfo: nil) throw NSError(domain: "", code: 0, userInfo: nil)
} }
#if canImport(RCTVideoCache) #if USE_VIDEO_CACHING
if self._videoCache.shouldCache(source:source, textTracks:self._textTracks) { if self._videoCache.shouldCache(source:source, textTracks:self._textTracks) {
return self._videoCache.playerItemForSourceUsingCache(uri: source.uri, assetOptions:assetOptions) return self._videoCache.playerItemForSourceUsingCache(uri: source.uri, assetOptions:assetOptions)
} }

View File

@ -77,7 +77,7 @@ class RCTVideoCachingHandler: NSObject, DVAssetLoaderDelegatesDelegate {
// MARK: - DVAssetLoaderDelegate // MARK: - DVAssetLoaderDelegate
func dvAssetLoaderDelegate(loaderDelegate:DVAssetLoaderDelegate!, didLoadData data:NSData!, forURL url:NSURL!) { func dvAssetLoaderDelegate(_ loaderDelegate: DVAssetLoaderDelegate!, didLoad data: Data!, for url: URL!) {
_videoCache.storeItem(data as Data?, forUri:url.absoluteString, withCallback:{ (success:Bool) in _videoCache.storeItem(data as Data?, forUri:url.absoluteString, withCallback:{ (success:Bool) in
DebugLog("Cache data stored successfully 🎉") DebugLog("Cache data stored successfully 🎉")
}) })

View File

@ -32,7 +32,10 @@ Pod::Spec.new do |s|
Pod::UI.puts "RNVideo: enable Video caching" Pod::UI.puts "RNVideo: enable Video caching"
ss.dependency "SPTPersistentCache", "~> 1.1.0" ss.dependency "SPTPersistentCache", "~> 1.1.0"
ss.dependency "DVAssetLoaderDelegate", "~> 0.3.1" ss.dependency "DVAssetLoaderDelegate", "~> 0.3.1"
ss.source_files = "ios/Video/**/*.{h,m,swift}" "ios/VideoCaching/**/*.{h,m,swift}" ss.source_files = "ios/*/**/*.{h,m,swift}"
ss.pod_target_xcconfig = {
'OTHER_SWIFT_FLAGS' => '$(inherited) -D USE_VIDEO_CACHING'
}
end end
end end