From f340025a09f47199c1109c8c30dca30bc515a77d Mon Sep 17 00:00:00 2001 From: Emrah Kaya Date: Sat, 9 Jun 2018 21:53:21 +0200 Subject: [PATCH] respecting cookies when opting in for headers (ios) --- ios/RCTVideo.m | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ios/RCTVideo.m b/ios/RCTVideo.m index 94b0223d..c8908734 100644 --- a/ios/RCTVideo.m +++ b/ios/RCTVideo.m @@ -328,12 +328,14 @@ static NSString *const timedMetadata = @"timedMetadata"; [[NSURL alloc] initFileURLWithPath:[[NSBundle mainBundle] pathForResource:uri ofType:type]]; if (isNetwork) { + NSMutableDictionary *assetOptions = [[NSMutableDictionary alloc]init]; if ([headers count] > 0) { - AVURLAsset* asset = [AVURLAsset URLAssetWithURL:url options:@{@"AVURLAssetHTTPHeaderFieldsKey": headers}]; - return [AVPlayerItem playerItemWithAsset:asset]; + [assetOptions setObject:@headers forKey:@"AVURLAssetHTTPHeaderFieldsKey"] } NSArray *cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]; - AVURLAsset *asset = [AVURLAsset URLAssetWithURL:url options:@{AVURLAssetHTTPCookiesKey : cookies}]; + [assetOptions setObject:@cookies forKey:@AVURLAssetHTTPCookiesKey] + + AVURLAsset *asset = [AVURLAsset URLAssetWithURL:url options:assetOptions]; return [AVPlayerItem playerItemWithAsset:asset]; } else if (isAsset) {