2016-09-09 3 views
0

Host.processMetadata()를 사용하여 비디오 스트림에서 ID3 태그를 가져옵니다. 이것은 Uint8Array로 제공되지만 제대로 디코딩하는 방법을 알 수 없다고합니다. 나는 다음을 사용하고있다 :chromecast 리시버 앱에서 id3 메타 데이터를 어떻게 디코딩합니까?

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

그러나 데이터를 올바르게 디코딩하지 않는다. 데이터를 얻으려면 어떻게해야합니까?

참조 : https://developers.google.com/cast/docs/reference/player/cast.player.api.Host#processMetadata

답변

0

여기입니다 어떻게 해결했는지 (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; 
    } 
    ... 
}; 
0

나는이 말을 알고 있지만, 나는이 같은 문제로 달리고, 나는 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] 
    })); 
    } 
} 
+0

후속 조치에 감사드립니다. 내 솔루션을 추가하라고 상기시켰다. 미안 나는 그것을 빨리하지 않았다 :) –

관련 문제