delphi - 在 DELPHI 中为 AVPlayer 设置用户代理
问题描述
我正在尝试根据下面的短代码在 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;
推荐阅读
- ios - 重命名核心数据实体而不丢失数据
- node.js - 如何防止在 Express.js 中的 req.body 中发送额外的东西
- sequelize.js - sequalize - 使用泛型类型从普通对象创建模型
- reactjs - 如何使用 useState 更新数组?
- arrays - Swift:如何从数组中的结构访问特定数据?
- java - 如何使用 VelocityTemplate 转义撇号
- dependency-injection - 对 gmock 对象应用 ON_CALL 无效
- mysql - Django 模型列行为
- python - 使用 tinytag 和 PIL 将字节转换为图像
- java - 如何将 charCount 集成到 for 循环中