【问题标题】:How do I decode id3 metadata in a chromecast receiver app?如何在 chromecast 接收器应用程序中解码 id3 元数据?
【发布时间】:2017-01-17 01:20:51
【问题描述】:

使用 Host.processMetadata() 获取视频流中的 ID3 标签。它说这是一个 Uint8Array 但我不知道如何正确解码。我正在使用:

new TextDecoder("utf-8").decode(data);

但是,这并没有正确解码数据。我如何获取数据?

参考:https://developers.google.com/cast/docs/reference/player/cast.player.api.Host#processMetadata

【问题讨论】:

    标签: chromecast google-cast id3 google-cast-sdk id3-tag


    【解决方案1】:

    这是我解决它的方法(由 Google 员工推荐)

    customReceiver.mediaHost.processMetadata = function (type, data, timestamp) {    
      var id3 = new TextDecoder("utf-8").decode(data.subarray(10));
      id3 = id3.replace(/\u0000/g, '');
      var id3Final;
      var id3Data = {
        type: 'meta',
        metadata: {}
      };
      if (id3.indexOf('TIT2') !== -1) {
        id3Final = id3.substring(5);
        id3Data.metadata.title = id3Final.substring(1);
        id3Data.metadata.TIT2 = id3Final;
      } else {
        id3Final = id3.substring(5);
        id3Data.metadata.TIT3 = id3Final;
      }
      ...
    };
    

    【讨论】:

      【解决方案2】:

      我知道这已经晚了,但我遇到了同样的问题,这就是我处理它以从 id3 标签中获取 TIT2 字符串的方式:

      // Receives and broadcasts TIT2 messages 
      myCustomPlayer.CastPlayer.prototype.processMetadata_ = function(type, data, timestamp) {
        var id3String = String.fromCharCode.apply(null, data);
        if (type === 'ID3' && /TIT2/.test(id3String)) {
          this.someMessageBus_.broadcast(JSON.stringify({
            id3Tag: id3String.split('|')[1]
          }));
        }
      }
      

      【讨论】:

      • 感谢您的跟进!它提醒我添加我的解决方案。对不起,我没有早点这样做:)
      猜你喜欢
      • 1970-01-01
      • 2014-06-17
      • 2020-04-21
      • 2016-07-02
      • 2020-05-17
      • 1970-01-01
      • 2015-04-16
      • 2014-12-29
      • 2013-08-14
      相关资源
      最近更新 更多