Restores optimization in AlbumUpnpProcessor and instead re-implements
default behavior in RecentAlbumUpnpProcessor subclass.
master
Allen Petersen 7 years ago
parent b4ef434c08
commit dcf41ce9e0
  1. 16
      airsonic-main/src/main/java/org/airsonic/player/service/upnp/AlbumUpnpProcessor.java
  2. 26
      airsonic-main/src/main/java/org/airsonic/player/service/upnp/RecentAlbumUpnpProcessor.java

@ -26,8 +26,10 @@ import org.airsonic.player.domain.CoverArtScheme;
import org.airsonic.player.domain.MediaFile; import org.airsonic.player.domain.MediaFile;
import org.airsonic.player.domain.MusicFolder; import org.airsonic.player.domain.MusicFolder;
import org.airsonic.player.service.SearchService; import org.airsonic.player.service.SearchService;
import org.fourthline.cling.support.model.BrowseResult;
import org.fourthline.cling.support.model.DIDLContent; import org.fourthline.cling.support.model.DIDLContent;
import org.fourthline.cling.support.model.PersonWithRole; import org.fourthline.cling.support.model.PersonWithRole;
import org.fourthline.cling.support.model.SortCriterion;
import org.fourthline.cling.support.model.container.Container; import org.fourthline.cling.support.model.container.Container;
import org.fourthline.cling.support.model.container.MusicAlbum; import org.fourthline.cling.support.model.container.MusicAlbum;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -59,6 +61,20 @@ public class AlbumUpnpProcessor extends UpnpContentProcessor <Album, MediaFile>
setRootTitle("Albums"); setRootTitle("Albums");
} }
/**
* Browses the top-level content of a type.
*/
public BrowseResult browseRoot(String filter, long firstResult, long maxResults, SortCriterion[] orderBy) throws Exception {
DIDLContent didl = new DIDLContent();
List<MusicFolder> allFolders = getDispatchingContentDirectory().getSettingsService().getAllMusicFolders();
List<Album> selectedItems = getAlbumDao().getAlphabeticalAlbums((int) firstResult, (int) maxResults, false, true, allFolders);
for (Album item : selectedItems) {
addItem(didl, item);
}
return createBrowseResult(didl, (int) didl.getCount(), getAllItemsSize());
}
public Container createContainer(Album album) throws Exception { public Container createContainer(Album album) throws Exception {
MusicAlbum container = new MusicAlbum(); MusicAlbum container = new MusicAlbum();

@ -20,6 +20,10 @@
package org.airsonic.player.service.upnp; package org.airsonic.player.service.upnp;
import org.airsonic.player.domain.Album; import org.airsonic.player.domain.Album;
import org.airsonic.player.domain.MusicFolder; import org.airsonic.player.domain.MusicFolder;
import org.airsonic.player.util.Util;
import org.fourthline.cling.support.model.BrowseResult;
import org.fourthline.cling.support.model.DIDLContent;
import org.fourthline.cling.support.model.SortCriterion;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
@ -37,6 +41,28 @@ public class RecentAlbumUpnpProcessor extends AlbumUpnpProcessor {
setRootTitle("RecentAlbums"); setRootTitle("RecentAlbums");
} }
/**
* Browses the top-level content.
*/
public BrowseResult browseRoot(String filter, long firstResult, long maxResults, SortCriterion[] orderBy) throws Exception {
// AlbumUpnpProcessor overrides browseRoot() with an optimization;
// this restores the default behavior for the subclass.
DIDLContent didl = new DIDLContent();
List<Album> allItems = getAllItems();
if (filter != null) {
// filter items (not implemented yet)
}
if (orderBy != null) {
// sort items (not implemented yet)
}
List<Album> selectedItems = Util.subList(allItems, firstResult, maxResults);
for (Album item : selectedItems) {
addItem(didl, item);
}
return createBrowseResult(didl, (int) didl.getCount(), allItems.size());
}
@Override @Override
public List<Album> getAllItems() { public List<Album> getAllItems() {
List<MusicFolder> allFolders = getDispatchingContentDirectory().getSettingsService().getAllMusicFolders(); List<MusicFolder> allFolders = getDispatchingContentDirectory().getSettingsService().getAllMusicFolders();

Loading…
Cancel
Save