我正在尝试根据以下短代码在 Delphi 中设置一个User Agent
for 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
图书馆,我需要设置用户代理那里。
它似乎正在做与此等效的事情:
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;
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句