I am trying to set a User Agent
for AvPlayer
in Delphi based on the short code below:
NSMutableDictionary* * *headers = [NSMutableDictionary dictionary];
[headers setObject:@"YourHeader"forKey:@"User-Agent"];
self.urlAsset = [AVURLAsset URLAssetWithURL:self.videoURL options:@{@"AVURLAssetHTTPHeaderFieldsKey" : headers}];
self.playerItem = [AVPlayerItem playerItemWithAsset:self.urlAsset];
self.player = [AVPlayer playerWithPlayerItem:self.playerItem];
I am having trouble with this part:
options:@{@"AVURLAssetHTTPHeaderFieldsKey" : headers}
I have declared headers as NSMutableDictionary
and setobject
with the necessary fields, but how should I assign that to the key AVURLAssetHTTPHeaderFieldsKey
?
I am using ALVideoPlayer
from Alcinoe
library and I need to set user agent there.
It appears to be doing the equivalent of this:
uses
Macapi.Foundation, Macapi.Helpers, Macapi.AVFoundation;
var
LDictionary: Pointer;
LOptions: NSDictionary;
LURLAsset: AVURLAsset;
LVideoURL: NSURL;
begin
// Make sure you initialize LVideoURL with whatever value it is expecting
LDictionary := TNSDictionary.OCClass.dictionaryWithObject(StringToID('YourHeader'), StringToID('User-Agent'));
LOptions := TNSDictionary.Wrap(TNSDictionary.OCClass.dictionaryWithObject(LDictionary, StringToID('AVURLAssetHTTPHeaderFieldsKey')));
LURLAsset := TAVURLAsset.OCClass.URLAssetWithURL(LVideoURL, LOptions);
// etc
end;