fix character encoding

This commit is contained in:
Wirlaburla 2023-01-08 23:59:24 -06:00
parent 5218286e53
commit d205bafebc

View File

@ -78,8 +78,9 @@ function startStation(new_station) {
// Start player using IcecastMetadataPlayer for the metadata.
// Use ?+date for avoiding problems with cache.
tuner.player = new IcecastMetadataPlayer(new_station.listen_url+"?"+Date.now(), {
onMetadata: (metadata) => {updateMetadata(metadata.StreamTitle);},
metadataTypes: ["icy"]
onMetadata: (metadata) => {updateMetadata(metadata.StreamTitle.decodeHTMLEntity());},
metadataTypes: ["icy"],
icyCharacterEncoding: "iso-8859-1"
});
// Start new context with analysers
@ -868,4 +869,15 @@ window.addEventListener('DOMContentLoaded', (event) => {
}
updateXHR();
});
});
String.prototype.decodeHTMLEntity = function() {
// As much as I don't want to do this... it works I guess.
var t = document.createElement('a');
t.innerHTML = this;
return t.innerText;
/* As much as I want to use this, it causes some issues with emojis
return this.replace(/&#(\d+);/g, function(match, dec) {
return String.fromCharCode(dec);
}); */
}