Show unplayed albums in a different colour.

Got an idea? Missing something? Post your feature request here.

Moderator: moderators

Show unplayed albums in a different colour.

Postby nickcw » Wed Apr 25, 2012 1:30 pm

When listing albums its not possible to tell which albums have been listened to.

Eg when listing albums it becomes easy to see that Album B has not yet been listened to...
>+ Artist - Album A
>+ Artist - Album B
>+ Artist - Album C

I have looked into this and it seems to me if the play count, for each album, was available to main.jsp then this info could be used to have a different css class if the number was 0 or above 0 allowing albums that have been played to be shown in a different colour to albums that have not been played.

I am assuming something needs to be done to main_jsp.java and then this needs recompiling to make the main_jsp.class

The trouble is I don't understand main_jsp.java or maybe I am not looking in the correct place.

Can anybody help me with this?
nickcw
 
Posts: 12
Joined: Thu Sep 08, 2011 10:19 am

Re: Show unplayed albums in a different colour.

Postby hakko » Wed Apr 25, 2012 3:25 pm

If you're using the latest official version, then the source code file you'd look into is MainController.java from version 4.6, found here: http://subsonic.svn.sourceforge.net/vie ... iew=markup

As you can see, MainController handles both "artist page" and "album page". It doesn't calculate plays per album on "artist page", so you'd have to add that, recompile and make some minor changes in main.jsp if I'm not completely wrong.

On line 87, it adds "children" which is a list of MusicFile. You'd have to calculate album play count the same way as it's done on line 107 for each album (currently, it's only done per artist or per single album, depending on what's being viewed). Traverse the MusicFiles in "children", calculate play count if it's a directory, and then pass the album play counts to main.jsp and add your CSS stuff there.

Hope that helps!
MusicCabinet developer
hakko
 
Posts: 1416
Joined: Tue Apr 17, 2012 7:05 pm
Location: Sweden

Re: Show unplayed albums in a different colour.

Postby nickcw » Wed Apr 25, 2012 3:45 pm

hakko wrote:If you're using the latest official version, then the source code file you'd look into is MainController.java from version 4.6, found here: http://subsonic.svn.sourceforge.net/vie ... iew=markup

As you can see, MainController handles both "artist page" and "album page". It doesn't calculate plays per album on "artist page", so you'd have to add that, recompile and make some minor changes in main.jsp if I'm not completely wrong.

On line 87, it adds "children" which is a list of MusicFile. You'd have to calculate album play count the same way as it's done on line 107 for each album (currently, it's only done per artist or per single album, depending on what's being viewed). Traverse the MusicFiles in "children", calculate play count if it's a directory, and then pass the album play counts to main.jsp and add your CSS stuff there.

Hope that helps!


Thanks I will give this a go and let you know how I get on.
nickcw
 
Posts: 12
Joined: Thu Sep 08, 2011 10:19 am

Re: Show unplayed albums in a different colour.

Postby nickcw » Wed Apr 25, 2012 6:44 pm

This is a stupid question but what is the repository url i need to put into netbeans.

I tried...
http://svn.sourceforge.net/viewvc/subso ... sonic-main

But I got the following message...
org.tigris.subversion.javahl.ClientException: Repository has been moved
Repository moved temporarily to 'http://sourceforge.net/apps/trac/sourceforge/wiki/Subversion'; please relocate
nickcw
 
Posts: 12
Joined: Thu Sep 08, 2011 10:19 am

Re: Show unplayed albums in a different colour.

Postby bushman4 » Wed Apr 25, 2012 7:05 pm

According to the redirect page, it looks like:

https://PROJECTNAME.svn.sourceforge.net ... ROJECTNAME

So:

https://subsonic.svn.sourceforge.net/svnroot/subsonic

would be my guess...

Glenn
Glenn Sullivan
Subsonic 6.1.6 (Unraid Docker)
90 regular Subsonic Users

Library as of 2024-10-28:
4,527 artists
19,996 albums
282,151 songs
10201.40 GB
41,583 hours
User avatar
bushman4
 
Posts: 875
Joined: Thu Dec 02, 2010 1:47 pm
Location: Massachusetts, USA

Re: Show unplayed albums in a different colour.

Postby nickcw » Thu Apr 26, 2012 11:38 am

bushman4 wrote:According to the redirect page, it looks like:

https://PROJECTNAME.svn.sourceforge.net ... ROJECTNAME

So:

https://subsonic.svn.sourceforge.net/svnroot/subsonic

would be my guess...

Glenn


Thanks. I looked at that URL and thought that does not look like the correct url to put into svn, should have thought to put it into a browser and read what it says.

So I now have...
Installed netbeans
Installed the svn plugin.
I have made the assumption that maven comes with netbeans and have not installed or downloaded maven separately.
Downloaded the source code for subsonic 4.6.
Opened subsonic-main\pom.xml
I then click run and select glassfish but I get the following error...
(I added extra flags to maven to get the full error)
<<<<
cd D:\code\subsonic-main; "JAVA_HOME=C:\\Program Files (x86)\\Java\\jdk1.6.0_31" "\"C:\\Program Files (x86)\\NetBeans 7.1.1\\java\\maven\\bin\\mvn.bat\"" -Dnetbeans.deploy=true --debug --errors -e -X package
Apache Maven 3.0.4 (r1232337; 2012-01-17 08:44:56+0000)
Maven home: C:\Program Files (x86)\NetBeans 7.1.1\java\maven\bin\..
Java version: 1.6.0_31, vendor: Sun Microsystems Inc.
Java home: C:\Program Files (x86)\Java\jdk1.6.0_31\jre
Default locale: en_GB, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"
Error stacktraces are turned on.
Reading global settings from C:\Program Files (x86)\NetBeans 7.1.1\java\maven\bin\..\conf\settings.xml
Reading user settings from C:\Users\nickcw\.m2\settings.xml
Using local repository at C:\Users\nickcw\.m2\repository
Using manager EnhancedLocalRepositoryManager with priority 10 for C:\Users\nickcw\.m2\repository
Scanning for projects...
The build could not read 1 project -> [Help 1]
org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
Non-resolvable parent POM: Failure to find net.sourceforge.subsonic:subsonic:pom:4.6 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ line 10, column 13

at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:363)
at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:636)
at org.apache.maven.DefaultMaven.getProjectsForMavenReactor(DefaultMaven.java:585)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:234)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)

The project net.sourceforge.subsonic:subsonic-main:4.6 (D:\code\subsonic-main\pom.xml) has 1 error
Non-resolvable parent POM: Failure to find net.sourceforge.subsonic:subsonic:pom:4.6 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ line 10, column 13 -> [Help 2]
org.apache.maven.model.resolution.UnresolvableModelException: Failure to find net.sourceforge.subsonic:subsonic:pom:4.6 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
at org.apache.maven.project.ProjectModelResolver.resolveModel(ProjectModelResolver.java:159)
at org.apache.maven.model.building.DefaultModelBuilder.readParentExternally(DefaultModelBuilder.java:813)
at org.apache.maven.model.building.DefaultModelBuilder.readParent(DefaultModelBuilder.java:664)
at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:310)
at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:232)
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:410)
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:379)
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:343)
at org.apache.maven.DefaultMaven.collectProjects(DefaultMaven.java:636)
at org.apache.maven.DefaultMaven.getProjectsForMavenReactor(DefaultMaven.java:585)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:234)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
Caused by: org.sonatype.aether.resolution.ArtifactResolutionException: Failure to find net.sourceforge.subsonic:subsonic:pom:4.6 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:538)
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:216)
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:193)
at org.sonatype.aether.impl.internal.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:286)
at org.apache.maven.project.ProjectModelResolver.resolveModel(ProjectModelResolver.java:155)
... 22 more
Caused by: org.sonatype.aether.transfer.ArtifactNotFoundException: Failure to find net.sourceforge.subsonic:subsonic:pom:4.6 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
at org.sonatype.aether.impl.internal.DefaultUpdateCheckManager.newException(DefaultUpdateCheckManager.java:230)
at org.sonatype.aether.impl.internal.DefaultUpdateCheckManager.checkArtifact(DefaultUpdateCheckManager.java:204)
at org.sonatype.aether.impl.internal.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:427)
... 26 more


For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/disp ... gException
[Help 2] http://cwiki.apache.org/confluence/disp ... lException

<<<<

Any ideas what is wrong?
nickcw
 
Posts: 12
Joined: Thu Sep 08, 2011 10:19 am

Re: Show unplayed albums in a different colour.

Postby hakko » Thu Apr 26, 2012 12:51 pm

Can you open up a command prompt, go to D:\code\subsonic-main, and run the command "mvn package" ?

If everything goes well, it should create a file called subsonic.war in D:\code\subsonic-main\target.
MusicCabinet developer
hakko
 
Posts: 1416
Joined: Tue Apr 17, 2012 7:05 pm
Location: Sweden

Re: Show unplayed albums in a different colour.

Postby nickcw » Thu Apr 26, 2012 2:33 pm

hakko wrote:Can you open up a command prompt, go to D:\code\subsonic-main, and run the command "mvn package" ?

If everything goes well, it should create a file called subsonic.war in D:\code\subsonic-main\target.


I tried that and it did not work at all as maven was not found as I only had the one bundled with netbeans.

So I installed maven from the maven website following the install instructions.

I then ran your command and I got the same error as the one I got when running in netbeans...
[INFO] Scanning for projects...
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project net.sourceforge.subsonic:subsonic-main:4.6 (D:\code\subsonic-main\pom.xml) has 1 error
[ERROR] Non-resolvable parent POM: Failure to find net.sourceforge.subsonic:subsonic:pom:4.6 in http://repo.maven.apache.org/maven2 was
cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced an
d 'parent.relativePath' points at wrong local POM @ line 10, column 13 -> [Help 2]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/disp ... gException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/disp ... lException
D:\code\subsonic-main>

Any ideas what I am doing wrong?

Have I got the correct pom.xml file open?
I have the one at this level open...
Directory of D:\code\subsonic-main

25/04/2012 22:20 <DIR> .
25/04/2012 22:20 <DIR> ..
25/04/2012 22:20 4,271 dreamplug.txt
25/04/2012 22:20 3,003 Getting Started.html
25/04/2012 22:20 35,819 LICENSE.TXT
25/04/2012 22:20 11,139 pom.xml
25/04/2012 22:20 540 README.TXT
25/04/2012 22:20 <DIR> src
25/04/2012 22:20 38,831 TODO.TXT
6 File(s) 93,603 bytes
3 Dir(s) 212,995,448,832 bytes free

D:\code\subsonic-main>
nickcw
 
Posts: 12
Joined: Thu Sep 08, 2011 10:19 am

Re: Show unplayed albums in a different colour.

Postby hakko » Thu Apr 26, 2012 3:07 pm

I did this a long time ago and it's slowly coming back.. you have to checkout not only subsonic-main, but the whole parent folder ("subsonic"), and build/install that before you can start building single projects. The pom.xml in subsonic-main refers to the parent pom.xml found in subsonic.

There's actually a guideline here: http://sourceforge.net/apps/mediawiki/s ... ows_Source
MusicCabinet developer
hakko
 
Posts: 1416
Joined: Tue Apr 17, 2012 7:05 pm
Location: Sweden

Re: Show unplayed albums in a different colour.

Postby nickcw » Thu Apr 26, 2012 4:15 pm

hakko wrote:I did this a long time ago and it's slowly coming back.. you have to checkout not only subsonic-main, but the whole parent folder ("subsonic"), and build/install that before you can start building single projects. The pom.xml in subsonic-main refers to the parent pom.xml found in subsonic.

There's actually a guideline here: http://sourceforge.net/apps/mediawiki/s ... ows_Source


Thanks for this. I now have it working.

I even have it working within netbeans so all I have to do is click run and it start the server and opens the webpage ready to login. Even though it worries me a little in the fact it picked up my real database listing all my music files.

Anyway now to actually code the feature, will let you know how I get on.
nickcw
 
Posts: 12
Joined: Thu Sep 08, 2011 10:19 am

Re: Show unplayed albums in a different colour.

Postby nickcw » Thu Apr 26, 2012 7:26 pm

So I have done it but it slows down the page load time.

This is the first java I have ever written so would be interested if you can spot ways of speeding it up.

Below are diffs of the 2 files I modified.

<<<<<<<<<<<<<<
# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: D:\code\release-4.6\subsonic-main\src\main\java\net\sourceforge\subsonic\controller
# This patch can be applied using context Tools: Patch action on respective folder.
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
Index: MainController.java
--- MainController.java Base (BASE)
+++ MainController.java Locally Modified (Based On LOCAL)
@@ -82,6 +82,22 @@
List<MusicFile> children = paths.length == 1 ? dir.getChildren(true, true, true) : getMultiFolderChildren(paths);
UserSettings userSettings = settingsService.getUserSettings(securityService.getCurrentUsername(request));

+ Map<String, Object> mapAlbumToPlayCount = new HashMap<String, Object>();
+ Map<String, Object> mapAlbumToNumTracks = new HashMap<String, Object>();
+ for (MusicFile child : children) {
+ if (child.isDirectory()) {
+ MusicFileInfo musicInfo = musicInfoService.getMusicFileInfoForPath(child.getPath());
+ int playCount = musicInfo == null ? 0 : musicInfo.getPlayCount();
+ mapAlbumToPlayCount.put(child.getName(),playCount);
+
+ List<MusicFile> grandChildren = child.getChildren(true, true, true);
+ int numTracks = grandChildren.size();
+ mapAlbumToNumTracks.put(child.getName(),numTracks);
+ }
+ }
+ map.put("mapAlbumToPlayCount",mapAlbumToPlayCount);
+ map.put("mapAlbumToNumTracks",mapAlbumToNumTracks);
+
map.put("dir", dir);
map.put("ancestors", getAncestors(dir));
map.put("children", children);
<<<<<<<<<<<<<<

<<<<<<<<<<<<<<
# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: D:\code\release-4.6\subsonic-main\src\main\webapp\WEB-INF\jsp
# This patch can be applied using context Tools: Patch action on respective folder.
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
Index: main.jsp
--- main.jsp Base (BASE)
+++ main.jsp Locally Modified (Based On LOCAL)
@@ -253,7 +253,7 @@
<sub:param name="path" value="${child.path}"/>
</sub:url>
<td style="padding-left:0.25em" colspan="4">
- <a href="${childUrl}" title="${child.name}"><span style="white-space:nowrap;"><str:truncateNicely upper="${cutoff}">${child.name}</str:truncateNicely></span></a>
+ <a href="${childUrl}" title="${child.name}"><span style="white-space:nowrap;"><str:truncateNicely upper="${cutoff}">${child.name}</str:truncateNicely> (Played ${model.mapAlbumToPlayCount[child.name]} of ${model.mapAlbumToNumTracks[child.name]})</span></a>
</td>
</c:when>

<<<<<<<<<<<<<<
nickcw
 
Posts: 12
Joined: Thu Sep 08, 2011 10:19 am


Return to Feature Requests

Who is online

Users browsing this forum: No registered users and 3 guests