OK. Here we go:
This is how to add a "Random" option to the "More Actions..." dropdown in playlist.jsp.
Start editing playlist.jsp.
Here is what we are going to edit first:
- Code: Select all
<!-- actionSelected() is invoked when the users selects from the "More actions..." combo box. -->
function actionSelected(id) {
if (id == "top") {
return;
} else if (id == "loadPlaylist") {
parent.frames.main.location.href = "loadPlaylist.view?";
} else if (id == "savePlaylist") {
parent.frames.main.location.href = "savePlaylist.view?";
} else if (id == "downloadPlaylist") {
location.href = "download.view?player=${model.player.id}";
} else if (id == "sharePlaylist") {
parent.frames.main.location.href = "createShare.view?player=${model.player.id}&" + getSelectedIndexes();
} else if (id == "sortByTrack") {
onSortByTrack();
} else if (id == "sortByArtist") {
onSortByArtist();
} else if (id == "sortByAlbum") {
onSortByAlbum();
} else if (id == "selectAll") {
selectAll(true);
} else if (id == "selectNone") {
selectAll(false);
} else if (id == "removeSelected") {
onRemoveSelected();
} else if (id == "download") {
location.href = "download.view?player=${model.player.id}&" + getSelectedIndexes();
} else if (id == "appendPlaylist") {
parent.frames.main.location.href = "appendPlaylist.view?player=${model.player.id}&" + getSelectedIndexes();
}
$("moreActions").selectedIndex = 0;
}
Add an else if that looks like this:
- Code: Select all
} else if (id == "randomPlaylist") {
parent.frames.hidden.location.href = "randomPlaylist.view?size=30&genre=any&year=any&musicFolderId=-1";
Now, we are going to add the actual "Random" link to the dropdown. Here is what we are going to edit:
- Code: Select all
<td style="white-space:nowrap;"><select id="moreActions" onchange="actionSelected(this.options[selectedIndex].id)">
<option id="top" selected="selected"><fmt:message key="playlist.more"/></option>
<option style="color:blue;"><fmt:message key="playlist.more.playlist"/></option>
<option id="loadPlaylist"> <fmt:message key="playlist.load"/></option>
<c:if test="${model.user.playlistRole}">
<option id="savePlaylist"> <fmt:message key="playlist.save"/></option>
</c:if>
<c:if test="${model.user.downloadRole}">
<option id="downloadPlaylist"> <fmt:message key="common.download"/></option>
</c:if>
<c:if test="${model.user.shareRole}">
<option id="sharePlaylist"> <fmt:message key="main.more.share"/></option>
</c:if>
<option id="sortByTrack"> <fmt:message key="playlist.more.sortbytrack"/></option>
<option id="sortByAlbum"> <fmt:message key="playlist.more.sortbyalbum"/></option>
<option id="sortByArtist"> <fmt:message key="playlist.more.sortbyartist"/></option>
<option style="color:blue;"><fmt:message key="playlist.more.selection"/></option>
<option id="selectAll"> <fmt:message key="playlist.more.selectall"/></option>
<option id="selectNone"> <fmt:message key="playlist.more.selectnone"/></option>
<option id="removeSelected"> <fmt:message key="playlist.remove"/></option>
<c:if test="${model.user.downloadRole}">
<option id="download"> <fmt:message key="common.download"/></option>
</c:if>
<c:if test="${model.user.playlistRole}">
<option id="appendPlaylist"> <fmt:message key="playlist.append"/></option>
</c:if>
</select>
</td>
I added spaces to highlight where the loadPlaylist option is.. We are going to put the random option right above it.
Here is what we are going to add:
- Code: Select all
<option id="randomPlaylist"> Random</option>
At this point, everything will work. However, when you select "Random" from the dropdown, it will take the main frame to more.view after filling the playlist.
If you want to prevent that from happening, edit subsonic-servlet.xml. Here is what we are going to edit:
- Code: Select all
<bean id="randomPlaylistController" class="net.sourceforge.subsonic.controller.RandomPlaylistController">
<property name="viewName" value="reload"/>
<property name="playerService" ref="playerService"/>
<property name="searchService" ref="searchService"/>
<property name="reloadFrames">
<list>
<bean class="net.sourceforge.subsonic.controller.ReloadFrame">
<property name="frame" value="playlist"/>
<property name="view" value="playlist.view?"/>
</bean>
<bean class="net.sourceforge.subsonic.controller.ReloadFrame">
<property name="frame" value="main"/>
<property name="view" value="nowPlaying.view?"/>
</bean>
</list>
</property>
</bean>
Just comment the reload frame main bean like this:
- Code: Select all
<bean id="randomPlaylistController" class="net.sourceforge.subsonic.controller.RandomPlaylistController">
<property name="viewName" value="reload"/>
<property name="playerService" ref="playerService"/>
<property name="searchService" ref="searchService"/>
<property name="reloadFrames">
<list>
<bean class="net.sourceforge.subsonic.controller.ReloadFrame">
<property name="frame" value="playlist"/>
<property name="view" value="playlist.view?"/>
</bean>
<!-- <bean class="net.sourceforge.subsonic.controller.ReloadFrame">
<property name="frame" value="main"/>
<property name="view" value="nowPlaying.view?"/>
</bean> -->
</list>
</property>
</bean>
And you are done!
Hope this helps!