|
|
@ -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,29 @@ 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 |
|
|
|
public List<Album> getAllItems() { |
|
|
|
public List<Album> getAllItems() { |
|
|
|
List<MusicFolder> allFolders = getDispatchingContentDirectory().getSettingsService().getAllMusicFolders(); |
|
|
|
List<MusicFolder> allFolders = getDispatchingContentDirectory().getSettingsService().getAllMusicFolders(); |
|
|
|
List<Album> recentAlbums = getAlbumDao().getNewestAlbums(0, RECENT_COUNT, allFolders); |
|
|
|
List<Album> recentAlbums = getAlbumDao().getNewestAlbums(0, RECENT_COUNT, allFolders); |
|
|
@ -51,4 +78,11 @@ public class RecentAlbumUpnpProcessor extends AlbumUpnpProcessor { |
|
|
|
} |
|
|
|
} |
|
|
|
return recentAlbums; |
|
|
|
return recentAlbums; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public int getAllItemsSize() throws Exception { |
|
|
|
|
|
|
|
List<MusicFolder> allFolders = getDispatchingContentDirectory().getSettingsService().getAllMusicFolders(); |
|
|
|
|
|
|
|
int allAlbumCount = getAlbumDao().getAlbumCount(allFolders); |
|
|
|
|
|
|
|
return Math.min(allAlbumCount, RECENT_COUNT); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|