如何在 chromecast 接收器应用程序中解码 id3 元数据?

How do I decode id3 metadata in a chromecast receiver app?

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

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

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

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

我知道这已经晚了,但我 运行 遇到了同样的问题,这就是我从 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]
    }));
  }
}

我是这样解决的(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;
  }
  ...
};