Page 1 of 1

Prevent Player Cache Issues [Done]

Posted: 11 Dec 2012, 21:00
by Madsonic
I know this is in a million other posts, so I started a new topic. I developed a method of preventing the common browser cache issues that cause the player to appear to begin loading, but stops the music within the first few seconds of playback.

After this modification, you will rarely if ever have to clear your cache to play a song.

Basically, we are going to salt the URL passed to the player in playqueue.jsp.
Because the cache stores separate info for each unique URL, this will prevent the cache from re-caching the same URL over and over, which is what causes the problem in the first place.

We are going to edit playqueue.jsp.

Here is the part of the file we are going to edit:

Code: Select all

function skip(index) {
        if (index < 0 || index >= songs.length) {
            return;
        }

        var song = songs[index];
        currentStreamUrl = song.streamUrl;
        updateCurrentImage();
        var list = new Array();
        list[0] = {
            file:song.streamUrl,
            title:song.title,
            provider:"sound"
        };

        if (song.duration != null) {
            list[0].duration = song.duration;
        }
        if (song.format == "aac" || song.format == "m4a") {
            list[0].provider = "video";
        }

        player.sendEvent("LOAD", list);
        player.sendEvent("PLAY");
    }
All you have to do, is replace it with this:

Code: Select all

function skip(index) {
        if (index < 0 || index >= songs.length) {
            return;
        }

        var song = songs[index];
        var saltedUrl = song.streamUrl + "&salt=" + Math.floor(Math.random()*100000);
        
        currentStreamUrl = song.streamUrl;
        updateCurrentImage();
        var list = new Array();
        list[0] = {
            file:saltedUrl,
            title:song.title,
            provider:"sound"
        };

        if (song.duration != null) {
            list[0].duration = song.duration;
        }
        if (song.format == "aac" || song.format == "m4a") {
            list[0].provider = "video";
        }

        player.sendEvent("LOAD", list);
        player.sendEvent("PLAY");
    }
That will append a parameter named "salt" to the end of the URL and the value of the parameter will be picked randomly.

Hope this helps!

Re: Prevent Player Cache Issues

Posted: 02 Jan 2013, 05:02
by gurutech
Just searched my playlist.jsp and don't see the skip(index) function.

Can I just add the modified code to the file, or am I out of luck? Running build 3292.

Thanks!

Re: Prevent Player Cache Issues

Posted: 02 Jan 2013, 19:00
by Madsonic
This is already been implemented in madsonic, but since 4.7/4.8 it's in playqueue.jsp instead of playlist.jsp

best regards

Re: Prevent Player Cache Issues

Posted: 02 Jan 2013, 23:44
by gurutech
Then this isn't the cause of the problems I'm having. :|

It must be something with how some of my MP3's were ripped (quality or compatibility?) MadSonic will play most of them just fine, but a select few will not play at all. These ones that don't play WILL play in another music player, so that leaves just the transcoder (ffmpeg?) that can't read the files for some reason.

Any way to test this?

Re: Prevent Player Cache Issues

Posted: 03 Jan 2013, 09:10
by Madsonic
Can you send me one file to test with my server and settings?
best regards

Re: Prevent Player Cache Issues

Posted: 03 Jan 2013, 12:42
by gurutech

Re: AW: Prevent Player Cache Issues

Posted: 03 Jan 2013, 14:38
by Madsonic
I will check this, in the next days.