Page 1 of 1

Prevent Player Cache Issues

PostPosted: Fri Jan 13, 2012 6:19 pm
by ytechie
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 playlist.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 playlist.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! :D

Re: Prevent Player Cache Issues

PostPosted: Fri Jan 13, 2012 7:13 pm
by bushman4
yTechie, do you share these with Sindre?

I hope so... although it sounds like he should just do a forum search for your posts with the Code attribute and he'd be good to check in most of these changes straight away!

Thanks for all you are doing,

Glenn

Re: Prevent Player Cache Issues

PostPosted: Fri Jan 13, 2012 7:52 pm
by ytechie
Thank you! I have more mods that I haven't posted yet, but if people want them, I will be glad to share! :D

By the way, I would love to know which users implemented which of my mods on their systems.

Re: Prevent Player Cache Issues

PostPosted: Tue Jan 17, 2012 9:52 pm
by mfrt
This salting of playlist.jsp seems to have fixed the problem for me. Thanks!

mfrt
Subsonic 4.6
Windows 7 Ultimate 64-bit

Re: Prevent Player Cache Issues

PostPosted: Thu Jan 19, 2012 7:41 pm
by klaauser
this has, apparently, helped me too! I will post back if the issue happens again. Thanks a ton!!

Version 4.6 (build 2583) – December 6, 2011
Server jetty-6.1.x, java 1.6.0_29, Windows 7 (73.4 MB / 96.7 MB)

Re: Prevent Player Cache Issues

PostPosted: Mon Apr 02, 2012 3:17 pm
by tsquillario
Has this been included in the next release?

I wonder if doing this on the client side instead will help? MiniSub is having issues with Chrome's HTML5 audio implementation. Thinking this is part of the issue.

Re: Prevent Player Cache Issues

PostPosted: Tue Apr 03, 2012 3:51 am
by ytechie
tsquillario wrote:I wonder if doing this on the client side instead will help? MiniSub is having issues with Chrome's HTML5 audio implementation. Thinking this is part of the issue.


Do you mean doing this on the server side? I've been using this mod since I figured it out, and it's been one of my best mods! Saves me so much time!

Re: Prevent Player Cache Issues

PostPosted: Wed Aug 29, 2012 5:56 pm
by mnksauce
I've been playing around with the newer 4.7 builds (currently beta 3). I believe I'm running into the same issue, but I think the playlist.jsp has changed. Any chance I can get an update on this fix for 4.7 beta 3?

Re: Prevent Player Cache Issues

PostPosted: Sun Sep 02, 2012 12:35 pm
by gacopl
the function you need to change in v4.7 b3 is in file playQueue.jsp

thank god for grep :)

Re: Prevent Player Cache Issues

PostPosted: Tue Sep 04, 2012 9:54 pm
by mnksauce
gacopl wrote:the function you need to change in v4.7 b3 is in file playQueue.jsp

thank god for grep :)


GAH! Thank you! Sad enough, I grep through files all day on the job. Maybe I should remember to apply what I learn.

Thanks again.

:D

Re: Prevent Player Cache Issues

PostPosted: Sat Nov 24, 2012 1:31 am
by lars mars
not a big friend of 'over'modding ss senselessly with 100 of little things you barely ever use.....
that said, this little tweak is the best thing i came across in a long time!!!! works great! obvious improvement of an annoying issue.

5 thumbs up for it m8!!!!! thx and keep it up!

L

Re: Prevent Player Cache Issues

PostPosted: Thu Oct 31, 2013 4:30 pm
by jValdron
I have Subsonic 4.8 stable under Ubuntu, and was trying to do this. Subsonic is installed in /usr/share/subsonic. However, now they package everything into a subsonic.war file. This file is essentially a ZIP file.

So one could easily do this:
Code: Select all
cd /usr/share/subsonic

# unzip the war file
unzip -d war subsonic.war

# make a backup of the war file
mv subsonic.war subsonic.war.bak

cd war/WEB-INF/jsp

# nano or whatever editor you like
nano playQueue.jsp
# perform the modifications described as per OP
# save the file

# create a war (zip) file of the new files
cd ../../
zip -r subsonic.war *
mv subsonic.war ../

# then restart subsonic
/etc/init.d/subsonic restart