org.fourthline.cling.support.model.BrowseResult Java Examples
The following examples show how to use
org.fourthline.cling.support.model.BrowseResult.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RecentAlbumUpnpProcessor.java From airsonic-advanced with GNU General Public License v3.0 | 6 votes |
/** * 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()); }
Example #2
Source File: UpnpContentProcessor.java From airsonic with GNU General Public License v3.0 | 6 votes |
/** * 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<T> allItems = getAllItems(); if (filter != null) { // filter items (not implemented yet) } if (orderBy != null) { // sort items (not implemented yet) } List<T> selectedItems = Util.subList(allItems, firstResult, maxResults); for (T item : selectedItems) { addItem(didl, item); } return createBrowseResult(didl, (int) didl.getCount(), allItems.size()); }
Example #3
Source File: UpnpContentProcessor.java From airsonic with GNU General Public License v3.0 | 6 votes |
/** * Browses a child of the container. */ public BrowseResult browseObject(String id, String filter, long firstResult, long maxResults, SortCriterion[] orderBy) throws Exception { T item = getItemById(id); List<U> allChildren = getChildren(item); if (filter != null) { // filter items (not implemented yet) } if (orderBy != null) { // sort items (not implemented yet) } List<U> selectedChildren = Util.subList(allChildren, firstResult, maxResults); DIDLContent didl = new DIDLContent(); for (U child : selectedChildren) { addChild(didl, child); } return createBrowseResult(didl, selectedChildren.size(), allChildren.size()); }
Example #4
Source File: GenreUpnpProcessor.java From airsonic with GNU General Public License v3.0 | 6 votes |
/** * Browses the top-level content of a type. */ public BrowseResult browseRoot(String filter, long firstResult, long maxResults, SortCriterion[] orderBy) throws Exception { // we have to override this to do an index-based id. DIDLContent didl = new DIDLContent(); List<Genre> allItems = getAllItems(); if (filter != null) { // filter items } if (orderBy != null) { // sort items } List<Genre> selectedItems = Util.subList(allItems, firstResult, maxResults); for (int i = 0; i < selectedItems.size(); i++) { Genre item = selectedItems.get(i); didl.addContainer(createContainer(item, (int) (i + firstResult))); } return createBrowseResult(didl, (int) didl.getCount(), allItems.size()); }
Example #5
Source File: UpnpContentProcessor.java From airsonic with GNU General Public License v3.0 | 6 votes |
public BrowseResult searchByName(String name, long firstResult, long maxResults, SortCriterion[] orderBy) { DIDLContent didl = new DIDLContent(); Class clazz = (Class) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]; try { List<MusicFolder> allFolders = getDispatchingContentDirectory().getSettingsService().getAllMusicFolders(); ParamSearchResult<T> result = getDispatcher().getSearchService().searchByName(name, (int) firstResult, (int) maxResults, allFolders, clazz); List<T> selectedItems = result.getItems(); for (T item : selectedItems) { addItem(didl, item); } return createBrowseResult(didl, (int) didl.getCount(), result.getTotalHits()); } catch (Exception e) { return null; } }
Example #6
Source File: RecentAlbumUpnpProcessor.java From airsonic with GNU General Public License v3.0 | 6 votes |
/** * 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()); }
Example #7
Source File: FolderBasedContentDirectory.java From subsonic with GNU General Public License v3.0 | 6 votes |
private BrowseResult browseRootMetadata() throws Exception { StorageFolder root = new StorageFolder(); root.setId(CONTAINER_ID_ROOT); root.setParentID("-1"); MediaLibraryStatistics statistics = settingsService.getMediaLibraryStatistics(); root.setStorageUsed(statistics == null ? 0 : statistics.getTotalLengthInBytes()); root.setTitle("Subsonic Media"); root.setRestricted(true); root.setSearchable(false); root.setWriteStatus(WriteStatus.NOT_WRITABLE); List<MusicFolder> musicFolders = settingsService.getAllMusicFolders(); root.setChildCount(musicFolders.size() + 1); // +1 for playlists DIDLContent didl = new DIDLContent(); didl.addContainer(root); return createBrowseResult(didl, 1, 1); }
Example #8
Source File: UpnpContentProcessor.java From airsonic-advanced with GNU General Public License v3.0 | 6 votes |
public BrowseResult searchByName(String name, long firstResult, long maxResults, SortCriterion[] orderBy) { DIDLContent didl = new DIDLContent(); Class clazz = (Class) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0]; try { List<MusicFolder> allFolders = getDispatchingContentDirectory().getSettingsService().getAllMusicFolders(); ParamSearchResult<T> result = getDispatcher().getSearchService().searchByName(name, (int) firstResult, (int) maxResults, allFolders, clazz); List<T> selectedItems = result.getItems(); for (T item : selectedItems) { addItem(didl, item); } return createBrowseResult(didl, (int) didl.getCount(), result.getTotalHits()); } catch (Exception e) { return null; } }
Example #9
Source File: UpnpContentProcessor.java From airsonic-advanced with GNU General Public License v3.0 | 6 votes |
/** * Browses a child of the container. */ public BrowseResult browseObject(String id, String filter, long firstResult, long maxResults, SortCriterion[] orderBy) throws Exception { T item = getItemById(id); List<U> allChildren = getChildren(item); if (filter != null) { // filter items (not implemented yet) } if (orderBy != null) { // sort items (not implemented yet) } List<U> selectedChildren = Util.subList(allChildren, firstResult, maxResults); DIDLContent didl = new DIDLContent(); for (U child : selectedChildren) { addChild(didl, child); } return createBrowseResult(didl, selectedChildren.size(), allChildren.size()); }
Example #10
Source File: BeyondContentDirectoryService.java From BeyondUPnP with Apache License 2.0 | 6 votes |
@Override public BrowseResult browse(String objectID, BrowseFlag browseFlag, String filter, long firstResult, long maxResults, SortCriterion[] orderby) throws ContentDirectoryException { String address = Utils.getIPAddress(true); String serverUrl = "http://" + address + ":" + JettyResourceServer.JETTY_SERVER_PORT; //Create container by id Container resultBean = ContainerFactory.createContainer(objectID, serverUrl); DIDLContent content = new DIDLContent(); for (Container c : resultBean.getContainers()) content.addContainer(c); for (Item item : resultBean.getItems()) content.addItem(item); int count = resultBean.getChildCount(); String contentModel = ""; try { contentModel = new DIDLParser().generate(content); } catch (Exception e) { throw new ContentDirectoryException( ContentDirectoryErrorCode.CANNOT_PROCESS, e.toString()); } return new BrowseResult(contentModel, count, count); }
Example #11
Source File: UpnpContentProcessor.java From airsonic-advanced with GNU General Public License v3.0 | 6 votes |
/** * 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<T> allItems = getAllItems(); if (filter != null) { // filter items (not implemented yet) } if (orderBy != null) { // sort items (not implemented yet) } List<T> selectedItems = Util.subList(allItems, firstResult, maxResults); for (T item : selectedItems) { addItem(didl, item); } return createBrowseResult(didl, (int) didl.getCount(), allItems.size()); }
Example #12
Source File: GenreUpnpProcessor.java From airsonic-advanced with GNU General Public License v3.0 | 6 votes |
/** * Browses the top-level content of a type. */ public BrowseResult browseRoot(String filter, long firstResult, long maxResults, SortCriterion[] orderBy) throws Exception { // we have to override this to do an index-based id. DIDLContent didl = new DIDLContent(); List<Genre> allItems = getAllItems(); if (filter != null) { // filter items } if (orderBy != null) { // sort items } List<Genre> selectedItems = Util.subList(allItems, firstResult, maxResults); for (int i = 0; i < selectedItems.size(); i++) { Genre item = selectedItems.get(i); didl.addContainer(createContainer(item, (int) (i + firstResult))); } return createBrowseResult(didl, (int) didl.getCount(), allItems.size()); }
Example #13
Source File: FolderBasedContentDirectory.java From subsonic with GNU General Public License v3.0 | 5 votes |
private BrowseResult browseMediaFile(MediaFile mediaFile, long firstResult, long maxResults) throws Exception { List<MediaFile> allChildren = mediaFileService.getChildrenOf(mediaFile, true, true, true); List<MediaFile> selectedChildren = Util.subList(allChildren, firstResult, maxResults); DIDLContent didl = new DIDLContent(); for (MediaFile child : selectedChildren) { addContainerOrItem(didl, child); } return createBrowseResult(didl, selectedChildren.size(), allChildren.size()); }
Example #14
Source File: UpnpContentProcessor.java From airsonic with GNU General Public License v3.0 | 5 votes |
/** * Browses metadata for a child. */ public BrowseResult browseObjectMetadata(String id) throws Exception { T item = getItemById(id); DIDLContent didl = new DIDLContent(); addItem(didl, item); return createBrowseResult(didl, 1, 1); }
Example #15
Source File: FolderBasedContentDirectory.java From subsonic with GNU General Public License v3.0 | 5 votes |
private BrowseResult browseRoot(long firstResult, long maxResults) throws Exception { DIDLContent didl = new DIDLContent(); List<MusicFolder> allFolders = settingsService.getAllMusicFolders(); List<MusicFolder> selectedFolders = Util.subList(allFolders, firstResult, maxResults); for (MusicFolder folder : selectedFolders) { MediaFile mediaFile = mediaFileService.getMediaFile(folder.getPath()); addContainerOrItem(didl, mediaFile); } if (maxResults > selectedFolders.size()) { didl.addContainer(createPlaylistRootContainer()); } return createBrowseResult(didl, (int) didl.getCount(), allFolders.size() + 1); }
Example #16
Source File: FolderBasedContentDirectory.java From subsonic with GNU General Public License v3.0 | 5 votes |
private BrowseResult browsePlaylist(Playlist playlist, long firstResult, long maxResults) throws Exception { List<MediaFile> allChildren = playlistService.getFilesInPlaylist(playlist.getId()); List<MediaFile> selectedChildren = Util.subList(allChildren, firstResult, maxResults); DIDLContent didl = new DIDLContent(); for (MediaFile child : selectedChildren) { addContainerOrItem(didl, child); } return createBrowseResult(didl, selectedChildren.size(), allChildren.size()); }
Example #17
Source File: FolderBasedContentDirectory.java From subsonic with GNU General Public License v3.0 | 5 votes |
private BrowseResult browsePlaylistRoot(long firstResult, long maxResults) throws Exception { DIDLContent didl = new DIDLContent(); List<Playlist> allPlaylists = playlistService.getAllPlaylists(); List<Playlist> selectedPlaylists = Util.subList(allPlaylists, firstResult, maxResults); for (Playlist playlist : selectedPlaylists) { didl.addContainer(createPlaylistContainer(playlist)); } return createBrowseResult(didl, selectedPlaylists.size(), allPlaylists.size()); }
Example #18
Source File: FolderBasedContentDirectory.java From subsonic with GNU General Public License v3.0 | 5 votes |
@Override public BrowseResult browse(String objectId, BrowseFlag browseFlag, String filter, long firstResult, long maxResults, SortCriterion[] orderby) throws ContentDirectoryException { if (!settingsService.getLicenseInfo().isLicenseOrTrialValid()) { LOG.warn("UPnP/DLNA media server not available. Please upgrade to Subsonic Premium."); throw new ContentDirectoryException(ContentDirectoryErrorCode.CANNOT_PROCESS, "Please upgrade to Subsonic Premium"); } LOG.info("UPnP request - objectId: " + objectId + ", browseFlag: " + browseFlag + ", filter: " + filter + ", firstResult: " + firstResult + ", maxResults: " + maxResults); // maxResult == 0 means all. if (maxResults == 0) { maxResults = Integer.MAX_VALUE; } try { if (CONTAINER_ID_ROOT.equals(objectId)) { return browseFlag == BrowseFlag.METADATA ? browseRootMetadata() : browseRoot(firstResult, maxResults); } if (CONTAINER_ID_PLAYLIST_ROOT.equals(objectId)) { return browseFlag == BrowseFlag.METADATA ? browsePlaylistRootMetadata() : browsePlaylistRoot(firstResult, maxResults); } if (objectId.startsWith(CONTAINER_ID_PLAYLIST_PREFIX)) { int playlistId = Integer.parseInt(objectId.replace(CONTAINER_ID_PLAYLIST_PREFIX, "")); Playlist playlist = playlistService.getPlaylist(playlistId); return browseFlag == BrowseFlag.METADATA ? browsePlaylistMetadata(playlist) : browsePlaylist(playlist, firstResult, maxResults); } int mediaFileId = Integer.parseInt(objectId.replace(CONTAINER_ID_FOLDER_PREFIX, "")); MediaFile mediaFile = mediaFileService.getMediaFile(mediaFileId); return browseFlag == BrowseFlag.METADATA ? browseMediaFileMetadata(mediaFile) : browseMediaFile(mediaFile, firstResult, maxResults); } catch (Throwable x) { LOG.error("UPnP error: " + x, x); throw new ContentDirectoryException(ContentDirectoryErrorCode.CANNOT_PROCESS, x.toString()); } }
Example #19
Source File: SubsonicContentDirectory.java From subsonic with GNU General Public License v3.0 | 5 votes |
@Override public BrowseResult search(String containerId, String searchCriteria, String filter, long firstResult, long maxResults, SortCriterion[] orderBy) throws ContentDirectoryException { // You can override this method to implement searching! return super.search(containerId, searchCriteria, filter, firstResult, maxResults, orderBy); }
Example #20
Source File: Browse.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
public void success(ActionInvocation invocation) { log.fine("Successful browse action, reading output argument values"); BrowseResult result = new BrowseResult( invocation.getOutput("Result").getValue().toString(), (UnsignedIntegerFourBytes) invocation.getOutput("NumberReturned").getValue(), (UnsignedIntegerFourBytes) invocation.getOutput("TotalMatches").getValue(), (UnsignedIntegerFourBytes) invocation.getOutput("UpdateID").getValue() ); boolean proceed = receivedRaw(invocation, result); if (proceed && result.getCountLong() > 0 && result.getResult().length() > 0) { try { DIDLParser didlParser = new DIDLParser(); DIDLContent didl = didlParser.parse(result.getResult()); received(invocation, didl); updateStatus(Status.OK); } catch (Exception ex) { invocation.setFailure( new ActionException(ErrorCode.ACTION_FAILED, "Can't parse DIDL XML response: " + ex, ex) ); failure(invocation, null); } } else { received(invocation, new DIDLContent()); updateStatus(Status.NO_CONTENT); } }
Example #21
Source File: Browse.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
public boolean receivedRaw(ActionInvocation actionInvocation, BrowseResult browseResult) { /* if (log.isLoggable(Level.FINER)) { log.finer("-------------------------------------------------------------------------------------"); log.finer("\n" + XML.pretty(browseResult.getDidl())); log.finer("-------------------------------------------------------------------------------------"); } */ return true; }
Example #22
Source File: AbstractContentDirectoryService.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
/** * Override this method to implement searching of your content. * <p> * The default implementation returns an empty result. * </p> */ public BrowseResult search(String containerId, String searchCriteria, String filter, long firstResult, long maxResults, SortCriterion[] orderBy) throws ContentDirectoryException { try { return new BrowseResult(new DIDLParser().generate(new DIDLContent()), 0, 0); } catch (Exception ex) { throw new ContentDirectoryException(ErrorCode.ACTION_FAILED, ex.toString()); } }
Example #23
Source File: ContentDirectoryService.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
@Override public BrowseResult search(String containerId, String searchCriteria, String filter, long firstResult, long maxResults, SortCriterion[] orderBy) throws ContentDirectoryException { // You can override this method to implement searching! return super.search(containerId, searchCriteria, filter, firstResult, maxResults, orderBy); }
Example #24
Source File: CustomContentDirectory.java From airsonic-advanced with GNU General Public License v3.0 | 5 votes |
@Override public BrowseResult search(String containerId, String searchCriteria, String filter, long firstResult, long maxResults, SortCriterion[] orderBy) throws ContentDirectoryException { // You can override this method to implement searching! return super.search(containerId, searchCriteria, filter, firstResult, maxResults, orderBy); }
Example #25
Source File: AlbumUpnpProcessor.java From airsonic with GNU General Public License v3.0 | 5 votes |
/** * 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()); }
Example #26
Source File: MediaFileUpnpProcessor.java From airsonic with GNU General Public License v3.0 | 5 votes |
@Override // overriding for the case of browsing a file public BrowseResult browseObjectMetadata(String id) throws Exception { MediaFile item = getItemById(id); DIDLContent didl = new DIDLContent(); addChild(didl, item); return createBrowseResult(didl, 1, 1); }
Example #27
Source File: MediaFileUpnpProcessor.java From airsonic-advanced with GNU General Public License v3.0 | 5 votes |
@Override // overriding for the case of browsing a file public BrowseResult browseObjectMetadata(String id) throws Exception { MediaFile item = getItemById(id); DIDLContent didl = new DIDLContent(); addChild(didl, item); return createBrowseResult(didl, 1, 1); }
Example #28
Source File: AlbumUpnpProcessor.java From airsonic-advanced with GNU General Public License v3.0 | 5 votes |
/** * 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()); }
Example #29
Source File: CustomContentDirectory.java From airsonic with GNU General Public License v3.0 | 5 votes |
@Override public BrowseResult search(String containerId, String searchCriteria, String filter, long firstResult, long maxResults, SortCriterion[] orderBy) throws ContentDirectoryException { // You can override this method to implement searching! return super.search(containerId, searchCriteria, filter, firstResult, maxResults, orderBy); }
Example #30
Source File: AbstractContentDirectoryService.java From TVRemoteIME with GNU General Public License v2.0 | 5 votes |
/** * Override this method to implement searching of your content. * <p> * The default implementation returns an empty result. * </p> */ public BrowseResult search(String containerId, String searchCriteria, String filter, long firstResult, long maxResults, SortCriterion[] orderBy) throws ContentDirectoryException { try { return new BrowseResult(new DIDLParser().generate(new DIDLContent()), 0, 0); } catch (Exception ex) { throw new ContentDirectoryException(ErrorCode.ACTION_FAILED, ex.toString()); } }