在 DELPHI 中为 AVPlayer 设置用户代理
Setting User Agent for AVPlayer in DELPHI
我正在尝试根据以下短代码为 Delphi 中的 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}
我已将 headers 声明为 NSMutableDictionary
和 setobject
以及必要的字段,但我应该如何将其分配给键 AVURLAssetHTTPHeaderFieldsKey
?
我正在使用 Alcinoe
库中的 ALVideoPlayer
,我需要在那里设置用户代理。
它似乎做的相当于:
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;
我正在尝试根据以下短代码为 Delphi 中的 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}
我已将 headers 声明为 NSMutableDictionary
和 setobject
以及必要的字段,但我应该如何将其分配给键 AVURLAssetHTTPHeaderFieldsKey
?
我正在使用 Alcinoe
库中的 ALVideoPlayer
,我需要在那里设置用户代理。
它似乎做的相当于:
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;