fix: omit packager assets from caching (#1438)

This commit is contained in:
Laurin Quast
2019-01-24 13:15:58 +01:00
committed by GitHub
parent 0a1605f11c
commit 125d5dc9c5
7 changed files with 87 additions and 30 deletions

View File

@@ -463,6 +463,7 @@ static int const RCTVideoUnset = -1;
{
bool isNetwork = [RCTConvert BOOL:[source objectForKey:@"isNetwork"]];
bool isAsset = [RCTConvert BOOL:[source objectForKey:@"isAsset"]];
bool shouldCache = [RCTConvert BOOL:[source objectForKey:@"shouldCache"]];
NSString *uri = [source objectForKey:@"uri"];
NSString *type = [source objectForKey:@"type"];
@@ -483,9 +484,9 @@ static int const RCTVideoUnset = -1;
[assetOptions setObject:cookies forKey:AVURLAssetHTTPCookiesKey];
#if __has_include(<react-native-video/RCTVideoCache.h>)
if (!_textTracks) {
if (shouldCache && (!_textTracks || !_textTracks.count)) {
/* The DVURLAsset created by cache doesn't have a tracksWithMediaType property, so trying
* to bring in the text track code will crash. I suspect this is because the asset hasn't fully loaded.
* to bring in the text track code will crash. I suspect this is because the asset hasn't fully loaded.
* Until this is fixed, we need to bypass caching when text tracks are specified.
*/
DebugLog(@"Caching is not supported for uri '%@' because text tracks are not compatible with the cache. Checkout https://github.com/react-native-community/react-native-video/blob/master/docs/caching.md", uri);