【问题标题】:Setting User Agent for AVPlayer in DELPHI在 DELPHI 中为 AVPlayer 设置用户代理
【发布时间】:2019-03-15 15:23:14
【问题描述】:

我正在尝试根据下面的短代码在 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}

我已将标题声明为 NSMutableDictionarysetobject 以及必要的字段,但我应该如何将其分配给键 AVURLAssetHTTPHeaderFieldsKey

我正在使用来自Alcinoe 库的ALVideoPlayer,我需要在那里设置用户代理。

【问题讨论】:

    标签: delphi avplayer firemonkey


    【解决方案1】:

    似乎正在做与此等价的操作:

    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;
    

    【讨论】:

      猜你喜欢
      • 2021-06-15
      • 2018-11-20
      • 2013-01-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-01
      • 1970-01-01
      相关资源
      最近更新 更多