我试图根据以下简短代码在德尔菲中为AvPlayer
设置User Agent
:
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];
我在这部分方面遇到麻烦:
options:@{@"AVURLAssetHTTPHeaderFieldsKey" : headers}
我已将标题称为NSMutableDictionary
和setobject
,并具有必要字段,但是我应该如何将其分配给键AVURLAssetHTTPHeaderFieldsKey
?
我正在使用Alcinoe
库中的ALVideoPlayer
,我需要在此处设置用户代理。
it 出现与此相当:
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;