gsavio / player-shoutcast-html5

Responsive HMTL5 Web Player for SHOUTCast and Icecast streamings with cover art and lyrics
https://guilhermesavio.dev/player-shoutcast-html5/
MIT License
93 stars 58 forks source link

Cover Art keep refreshing every couples seconds #22

Closed DirtySkeMe closed 3 years ago

DirtySkeMe commented 4 years ago

Hello i'm really happy to have found this player i just found out about it and the original script ain't avaible to download i found it in one off the issue thread then i found couples files been edited the config.js and the script.js i did a remix of all those info i found i added it to 2 differents server

the 1st is regular http without cURL http://dirty.networkmechanics.co.uk/masterog on this one everything work beside the refresh ervery couples seconds making look on shoutcast like multiple listeners

2nd https with cURL https://syndicatedhiphop.tk/masterog nothing work but for this one i think it come from my settings on my apache maybe

but if i could make the one working so far stop to refresh every second be great

thank you

DirtySkeMe commented 4 years ago

found this to fix it thx @juanamm EDIT:

I found the error, I have corrected it with my little knowledge of javascript, maybe you will do better. In line 374 of the script.js an uppercase text (currentSongElement.innerText) was being compared with a lowercase text (song.trim()) for that reason the covert art and historic was continually being refreshed and slipped every 1 second.

if (currentSongElement.innerText !== song.trim()) {

After that I had trouble replacing the characters "&" in song.trim() and "&" in currentSongElement.innerText I had to make another modification. Replace element currentSongElement.innerText with decodedString and song.trim() with currentSong.trim()

In summary:

                   // Uppercase the song
        currentSong = currentSong.toUpperCase();

        // Formating songs characters to UTF-8
        var encodedStr = String(currentSongElement.innerText);
        var parser = new DOMParser;
        var dom = parser.parseFromString(
        '<!doctype html><body>' + encodedStr,
        'text/html');
        var decodedString = dom.body.textContent;

                    if (decodedString !== currentSong.trim()) {
DirtySkeMe commented 4 years ago

1 issue left on mobile the cover doen't update if it wasn't in the cash i think from now playing

gsavio commented 3 years ago

Hi @DirtySkeMe

I think I'm a little late, but could you tell me if your problem still exists?

found this to fix it thx @juanamm EDIT:

I found the error, I have corrected it with my little knowledge of javascript, maybe you will do better. In line 374 of the script.js an uppercase text (currentSongElement.innerText) was being compared with a lowercase text (song.trim()) for that reason the covert art and historic was continually being refreshed and slipped every 1 second.

if (currentSongElement.innerText !== song.trim()) {

After that I had trouble replacing the characters "&" in song.trim() and "&" in currentSongElement.innerText I had to make another modification. Replace element currentSongElement.innerText with decodedString and song.trim() with currentSong.trim()

In summary:

                   // Uppercase the song
      currentSong = currentSong.toUpperCase();

      // Formating songs characters to UTF-8
      var encodedStr = String(currentSongElement.innerText);
      var parser = new DOMParser;
      var dom = parser.parseFromString(
      '<!doctype html><body>' + encodedStr,
      'text/html');
      var decodedString = dom.body.textContent;

                    if (decodedString !== currentSong.trim()) {

The value that comes from the api also comes in upper case, so...

1 issue left on mobile the cover doen't update if it wasn't in the cash i think from now playing

On the request has a param in the last position called t, with timestamp just to avoid problems with cache. Check if this param is in your requests.