I'm attempting to load a video file that requires a token in the header. I learned on Stackverflow that this may be possible from looking at the following question. The problem is that I don't believe AVURLAssetHTTPHeaderFieldsKey is public or I have written my asset variable incorrectly. What I'm trying to do is add the token to the headers in order for the AVPlayer to load the video file. Here is my code so far which only shows the player but doesn't load the video I'm guessing because my headers aren't set correctly:
NSURL *videoURL = [NSURL URLWithString:cell.media[@"redirectionUrl"]];
NSMutableDictionary * headers = [NSMutableDictionary dictionary];
[headers setObject:[CMUser currentUser].token forKey:@"Authorization"];
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:videoURL options:@{@"AVURLAssetHTTPHeaderFieldsKey" : headers}];
AVPlayerItem * item = [AVPlayerItem playerItemWithAsset:asset];
AVPlayer *player = [[AVPlayer alloc] initWithPlayerItem:item];
AVPlayerViewController *playerViewController = [AVPlayerViewController new];
playerViewController.player = player;
playerViewController.modalPresentationStyle = UIModalPresentationOverFullScreen;
[self presentViewController:playerViewController animated:YES completion:nil];