GCKMediaInformation initWithContentID 已弃用警告
Posted
技术标签:
【中文标题】GCKMediaInformation initWithContentID 已弃用警告【英文标题】:GCKMediaInformation initWithContentID is deprecated warning 【发布时间】:2019-03-14 05:49:58 【问题描述】:在构建 GCKMediaInformation 时,我收到此警告:
'initWithContentID:streamType:contentType:metadata:streamDuration:mediaTracks:textTrackStyle:customData:' 已弃用:使用 GCKMediaInformationBuilder 进行初始化 GCKMediaInformation 对象。
这是我的方法:
GCKMediaInformation* mediaInfo = [[GCKMediaInformation alloc]
initWithContentID:[self.chromecastUrl absoluteString] // WARNING ON THIS LINE
streamType:self.videoPlayer.isLive ? GCKMediaStreamTypeLive
: GCKMediaStreamTypeBuffered
contentType:@"application/dash+xml"
metadata:metadata
streamDuration:duration
mediaTracks:nil
textTrackStyle:nil
customData:customData];
如何通过?
【问题讨论】:
【参考方案1】:如果有人在寻找 Swift 版本,这里就是。
let builder = GCKMediaInformationBuilder()
builder.contentType = "application/dash+xml"
builder.streamType = self.videoPlayer.isLive ? .live : .buffered
builder.metadata = metadata
builder.streamDuration = duration
builder.customData = customData
// set all other desired properties...
// then build the GCKMediaInformation with build method
let mediaInfo = builder.build()
【讨论】:
【参考方案2】:这是我通过使用GCKMediaInformationBuilder 构建媒体信息来传递该警告的方法:
GCKMediaInformationBuilder *builder =
[[GCKMediaInformationBuilder alloc] initWithContentURL:self.chromecastUrl];
builder.contentType = @"application/dash+xml";
builder.streamType = self.videoPlayer.isLive ? GCKMediaStreamTypeLive : GCKMediaStreamTypeBuffered;
builder.metadata = metadata;
builder.streamDuration = duration;
builder.customData = customData;
// set all other desired properties...
// then build the GCKMediaInformation with build method
GCKMediaInformation *mediaInfo = [builder build];
我希望这会有所帮助。
【讨论】:
以上是关于GCKMediaInformation initWithContentID 已弃用警告的主要内容,如果未能解决你的问题,请参考以下文章
将 iPhone 摄像头的实时 mp4 流投射到 Google Chromecast