【问题标题】:GCKMediaInformation initWithContentID is deprecated warningGCKMediaInformation initWithContentID 已弃用警告
【发布时间】: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];

如何通过?

【问题讨论】:

    标签: ios chromecast


    【解决方案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];
      

      我希望这会有所帮助。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-12-06
        • 2015-03-23
        • 2019-07-09
        • 1970-01-01
        • 2020-07-03
        • 1970-01-01
        • 1970-01-01
        • 2021-02-19
        相关资源
        最近更新 更多