我正在尝试根据以下简短代码在Delphi中为User Agent
设置一个AvPlayer
:
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
?
我正在使用ALVideoPlayer
库中的Alcinoe
,并且需要在此处设置用户代理。
答案 0 :(得分:0)
它似乎正在执行以下操作:
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;