Настройка User Agent для AVPlayer в DELPHI - PullRequest
0 голосов
/ 15 марта 2019

Я пытаюсь установить User Agent для AvPlayer в Delphi на основе короткого кода ниже:

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 и янужно установить там пользовательский агент.

1 Ответ

0 голосов
/ 15 марта 2019

Это кажется , что делает эквивалент этого:

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;
...