Java Code Examples for org.fourthline.cling.support.model.DIDLContent#addContainer()
The following examples show how to use
org.fourthline.cling.support.model.DIDLContent#addContainer() .
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: 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 2
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 3
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 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: MediaFileUpnpProcessor.java From airsonic-advanced with GNU General Public License v3.0 | 5 votes |
public void addChild(DIDLContent didl, MediaFile child) { if (child.isFile()) { didl.addItem(createItem(child)); } else { didl.addContainer(createContainer(child)); } }
Example 6
Source File: FolderBasedContentDirectory.java From subsonic with GNU General Public License v3.0 | 5 votes |
private void addContainerOrItem(DIDLContent didl, MediaFile mediaFile) throws Exception { if (mediaFile.isFile()) { didl.addItem(createItem(mediaFile)); } else { didl.addContainer(createContainer(mediaFile)); } }
Example 7
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 8
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 9
Source File: MediaFileUpnpProcessor.java From airsonic with GNU General Public License v3.0 | 5 votes |
public void addChild(DIDLContent didl, MediaFile child) { if (child.isFile()) { didl.addItem(createItem(child)); } else { didl.addContainer(createContainer(child)); } }
Example 10
Source File: MediaFileUpnpProcessor.java From airsonic with GNU General Public License v3.0 | 5 votes |
public void addItem(DIDLContent didl, MediaFile item) { if (item.isFile()) { didl.addItem(createItem(item)); } else { didl.addContainer(createContainer(item)); } }
Example 11
Source File: ArtistUpnpProcessor.java From airsonic with GNU General Public License v3.0 | 4 votes |
public void addChild(DIDLContent didl, Album album) { didl.addContainer(getAlbumProcessor().createContainer(album)); }
Example 12
Source File: UpnpContentProcessor.java From airsonic with GNU General Public License v3.0 | 4 votes |
/** * Browses the root metadata for a type. */ public BrowseResult browseRootMetadata() throws Exception { DIDLContent didl = new DIDLContent(); didl.addContainer(createRootContainer()); return createBrowseResult(didl, 1, 1); }
Example 13
Source File: UpnpContentProcessor.java From airsonic with GNU General Public License v3.0 | 4 votes |
public void addItem(DIDLContent didl, T item) { didl.addContainer(createContainer(item)); }
Example 14
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 15
Source File: FolderBasedContentDirectory.java From subsonic with GNU General Public License v3.0 | 4 votes |
private BrowseResult browsePlaylistRootMetadata() throws Exception { DIDLContent didl = new DIDLContent(); didl.addContainer(createPlaylistRootContainer()); return createBrowseResult(didl, 1, 1); }
Example 16
Source File: UpnpContentProcessor.java From airsonic-advanced with GNU General Public License v3.0 | 4 votes |
/** * Browses the root metadata for a type. */ public BrowseResult browseRootMetadata() throws Exception { DIDLContent didl = new DIDLContent(); didl.addContainer(createRootContainer()); return createBrowseResult(didl, 1, 1); }
Example 17
Source File: FolderBasedContentDirectory.java From subsonic with GNU General Public License v3.0 | 4 votes |
private BrowseResult browsePlaylistMetadata(Playlist playlist) throws Exception { DIDLContent didl = new DIDLContent(); didl.addContainer(createPlaylistContainer(playlist)); return createBrowseResult(didl, 1, 1); }
Example 18
Source File: ArtistUpnpProcessor.java From airsonic-advanced with GNU General Public License v3.0 | 4 votes |
public void addChild(DIDLContent didl, Album album) { didl.addContainer(getAlbumProcessor().createContainer(album)); }
Example 19
Source File: FolderBasedContentDirectory.java From subsonic with GNU General Public License v3.0 | 4 votes |
private BrowseResult browseMediaFileMetadata(MediaFile mediaFile) throws Exception { DIDLContent didl = new DIDLContent(); didl.addContainer(createContainer(mediaFile)); return createBrowseResult(didl, 1, 1); }
Example 20
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()); } }