Java Code Examples for org.fourthline.cling.support.model.BrowseFlag#METADATA
The following examples show how to use
org.fourthline.cling.support.model.BrowseFlag#METADATA .
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: 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 2
Source File: ContentDirectoryService.java From HPlayer with Apache License 2.0 | 4 votes |
@Override public BrowseResult browse(String objectID, BrowseFlag browseFlag, String s1, long l, long l1, SortCriterion[] sortCriterions) throws ContentDirectoryException { try { DIDLContent didl = new DIDLContent(); ContentNode contentNode = ContentTree.getNode(objectID); Log.d(TAG, "someone's browsing id: " + objectID); if (contentNode == null) { // 没有共享资源 return new BrowseResult("", 0, 0); } if (contentNode.isItem()) { // 是文件 didl.addItem(contentNode.getItem()); Log.v(TAG, "returing item: " + contentNode.getItem().getTitle()); return new BrowseResult(new DIDLParser().generate(didl), 1, 1); } else { // 是文件夹 if (browseFlag == BrowseFlag.METADATA) { didl.addContainer(contentNode.getContainer()); Log.v(TAG, "returning metadata of container: " + contentNode.getContainer().getTitle()); return new BrowseResult(new DIDLParser().generate(didl), 1, 1); } else { for (Container container : contentNode.getContainer().getContainers()) { didl.addContainer(container); Log.v(TAG, "getting child container: " + container.getTitle()); } for (Item item : contentNode.getContainer().getItems()) { didl.addItem(item); Log.v(TAG, "getting child item: " + item.getTitle()); } return new BrowseResult(new DIDLParser().generate(didl), contentNode.getContainer().getChildCount(), contentNode.getContainer().getChildCount()); } } } catch (Exception e) { throw new ContentDirectoryException( ContentDirectoryErrorCode.CANNOT_PROCESS, e.toString()); } }
Example 3
Source File: ContentDirectoryService.java From DroidDLNA with GNU General Public License v3.0 | 4 votes |
@Override public BrowseResult browse(String objectID, BrowseFlag browseFlag, String filter, long firstResult, long maxResults, SortCriterion[] orderby) throws ContentDirectoryException { // TODO Auto-generated method stub try { DIDLContent didl = new DIDLContent(); ContentNode contentNode = ContentTree.getNode(objectID); Log.v(LOGTAG, "someone's browsing id: " + objectID); if (contentNode == null) return new BrowseResult("", 0, 0); if (contentNode.isItem()) { didl.addItem(contentNode.getItem()); Log.v(LOGTAG, "returing item: " + contentNode.getItem().getTitle()); return new BrowseResult(new DIDLParser().generate(didl), 1, 1); } else { if (browseFlag == BrowseFlag.METADATA) { didl.addContainer(contentNode.getContainer()); Log.v(LOGTAG, "returning metadata of container: " + contentNode.getContainer().getTitle()); return new BrowseResult(new DIDLParser().generate(didl), 1, 1); } else { for (Container container : contentNode.getContainer() .getContainers()) { didl.addContainer(container); Log.v(LOGTAG, "getting child container: " + container.getTitle()); } for (Item item : contentNode.getContainer().getItems()) { didl.addItem(item); Log.v(LOGTAG, "getting child item: " + item.getTitle()); } return new BrowseResult(new DIDLParser().generate(didl), contentNode.getContainer().getChildCount(), contentNode.getContainer().getChildCount()); } } } catch (Exception ex) { throw new ContentDirectoryException( ContentDirectoryErrorCode.CANNOT_PROCESS, ex.toString()); } }