fix character encoding
This commit is contained in:
parent
5218286e53
commit
d205bafebc
16
radio.js
16
radio.js
|
@ -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
|
||||
|
@ -869,3 +870,14 @@ 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);
|
||||
}); */
|
||||
}
|
Reference in New Issue
Block a user