Prevent Player Cache Issues

Third-party modifications and add-ons, Apps and Clients

Moderator: moderators

Prevent Player Cache Issues

Postby ytechie » Fri Jan 13, 2012 6:19 pm

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
User avatar
ytechie
 
Posts: 547
Joined: Sun Dec 12, 2010 5:05 am
Location: Manhattan, New York

Re: Prevent Player Cache Issues

Postby bushman4 » Fri Jan 13, 2012 7:13 pm

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
Glenn Sullivan
Subsonic 5.2.1 (Standalone on Apache/Tomcat 6)
WHS 2003, Dual Core Athlon, 4 Gb RAM, 12 TB
50 regular Subsonic Users

Library as of 2016-03-21:
4,034 artists
16,595 albums
182,904 songs
4582.16 GB
21,558 hours
User avatar
bushman4
 
Posts: 867
Joined: Thu Dec 02, 2010 1:47 pm
Location: Massachusetts, USA

Re: Prevent Player Cache Issues

Postby ytechie » Fri Jan 13, 2012 7:52 pm

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.
User avatar
ytechie
 
Posts: 547
Joined: Sun Dec 12, 2010 5:05 am
Location: Manhattan, New York

Re: Prevent Player Cache Issues

Postby mfrt » Tue Jan 17, 2012 9:52 pm

This salting of playlist.jsp seems to have fixed the problem for me. Thanks!

mfrt
Subsonic 4.6
Windows 7 Ultimate 64-bit
User avatar
mfrt
 
Posts: 5
Joined: Tue Jan 17, 2012 4:28 pm

Re: Prevent Player Cache Issues

Postby klaauser » Thu Jan 19, 2012 7:41 pm

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)
klaauser
 
Posts: 4
Joined: Thu Jan 12, 2012 8:25 pm

Re: Prevent Player Cache Issues

Postby tsquillario » Mon Apr 02, 2012 3:17 pm

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.
Jamstash Developer
Chrome App - https://chrome.google.com/webstore/detail/jccdpflnecheidefpofmlblgebobbloc
Beta Site - http://beta.jamstash.com
GitHub Project - https://github.com/tsquillario/Jamstash
User avatar
tsquillario
 
Posts: 206
Joined: Thu Jun 30, 2011 5:10 pm
Location: State College, PA

Re: Prevent Player Cache Issues

Postby ytechie » Tue Apr 03, 2012 3:51 am

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!
User avatar
ytechie
 
Posts: 547
Joined: Sun Dec 12, 2010 5:05 am
Location: Manhattan, New York

Re: Prevent Player Cache Issues

Postby mnksauce » Wed Aug 29, 2012 5:56 pm

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?
mnksauce
 
Posts: 12
Joined: Tue Dec 08, 2009 7:55 am

Re: Prevent Player Cache Issues

Postby gacopl » Sun Sep 02, 2012 12:35 pm

the function you need to change in v4.7 b3 is in file playQueue.jsp

thank god for grep :)
gacopl
 
Posts: 7
Joined: Sun Sep 02, 2012 12:33 pm

Re: Prevent Player Cache Issues

Postby mnksauce » Tue Sep 04, 2012 9:54 pm

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
mnksauce
 
Posts: 12
Joined: Tue Dec 08, 2009 7:55 am

Re: Prevent Player Cache Issues

Postby lars mars » Sat Nov 24, 2012 1:31 am

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
lars mars
 
Posts: 70
Joined: Fri Aug 26, 2011 3:24 am

Re: Prevent Player Cache Issues

Postby jValdron » Thu Oct 31, 2013 4:30 pm

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
jValdron
 
Posts: 11
Joined: Wed Aug 29, 2012 4:47 pm


Return to Mods, Apps and Clients

Who is online

Users browsing this forum: No registered users and 2 guests