org.fourthline.cling.support.model.container.Container Java Examples

The following examples show how to use org.fourthline.cling.support.model.container.Container. 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: RootUpnpProcessor.java    From airsonic-advanced with GNU General Public License v3.0 6 votes vote down vote up
public Container createRootContainer() {
    StorageFolder root = new StorageFolder();
    root.setId(DispatchingContentDirectory.CONTAINER_ID_ROOT);
    root.setParentID("-1");

    MediaLibraryStatistics statistics = indexManager.getStatistics();
    // returning large storageUsed values doesn't play nicely with
    // some upnp clients
    //root.setStorageUsed(statistics == null ? 0 : statistics.getTotalLengthInBytes());
    root.setStorageUsed(-1L);
    root.setTitle("Airsonic Media");
    root.setRestricted(true);
    root.setSearchable(true);
    root.setWriteStatus(WriteStatus.NOT_WRITABLE);

    root.setChildCount(6);
    return root;
}
 
Example #2
Source File: AlbumUpnpProcessor.java    From airsonic with GNU General Public License v3.0 6 votes vote down vote up
public Container createContainer(Album album) {
    MusicAlbum container = new MusicAlbum();

    if (album.getId() == -1) {
        container.setId(getRootId() + DispatchingContentDirectory.SEPARATOR + album.getComment());
    } else {
        container.setId(getRootId() + DispatchingContentDirectory.SEPARATOR + album.getId());
        container.setAlbumArtURIs(new URI[] { getAlbumArtURI(album.getId()) });
        container.setDescription(album.getComment());
    }
    container.setParentID(getRootId());
    container.setTitle(album.getName());
    // TODO: correct artist?
    if (album.getArtist() != null) {
        container.setArtists(getAlbumArtists(album.getArtist()));
    }
    return container;
}
 
Example #3
Source File: FolderBasedContentDirectory.java    From airsonic with GNU General Public License v3.0 6 votes vote down vote up
private Container createContainer(MediaFile mediaFile) {
    Container container = mediaFile.isAlbum() ? createAlbumContainer(mediaFile) : new MusicAlbum();
    container.setId(CONTAINER_ID_FOLDER_PREFIX + mediaFile.getId());
    container.setTitle(mediaFile.getName());
    List<MediaFile> children = mediaFileService.getChildrenOf(mediaFile, true, true, false);
    container.setChildCount(children.size());

    container.setParentID(CONTAINER_ID_ROOT);
    if (!mediaFileService.isRoot(mediaFile)) {
        MediaFile parent = mediaFileService.getParentOf(mediaFile);
        if (parent != null) {
            container.setParentID(String.valueOf(parent.getId()));
        }
    }
    return container;
}
 
Example #4
Source File: MediaFileUpnpProcessor.java    From airsonic-advanced with GNU General Public License v3.0 6 votes vote down vote up
public Container createContainer(MediaFile item) {
    MusicAlbum container = new MusicAlbum();
    if (item.isAlbum()) {
        container.setAlbumArtURIs(new URI[] { getDispatcher().getAlbumProcessor().getAlbumArtURI(item.getId())});

        if (item.getArtist() != null) {
            container.setArtists(getDispatcher().getAlbumProcessor().getAlbumArtists(item.getArtist()));
        }
        container.setDescription(item.getComment());
    }
    container.setId(DispatchingContentDirectory.CONTAINER_ID_FOLDER_PREFIX + DispatchingContentDirectory.SEPARATOR + item.getId());
    container.setTitle(item.getName());
    List<MediaFile> children = getChildren(item);
    container.setChildCount(children.size());

    if (! getMediaFileService().isRoot(item)) {
        MediaFile parent = getMediaFileService().getParentOf(item);
        if (parent != null) {
            container.setParentID(String.valueOf(parent.getId()));
        }
    } else {
        container.setParentID(DispatchingContentDirectory.CONTAINER_ID_FOLDER_PREFIX);
    }
    return container;
}
 
Example #5
Source File: AlbumUpnpProcessor.java    From airsonic-advanced with GNU General Public License v3.0 6 votes vote down vote up
public Container createContainer(Album album) {
    MusicAlbum container = new MusicAlbum();

    if (album.getId() == -1) {
        container.setId(getRootId() + DispatchingContentDirectory.SEPARATOR + album.getComment());
    } else {
        container.setId(getRootId() + DispatchingContentDirectory.SEPARATOR + album.getId());
        container.setAlbumArtURIs(new URI[] { getAlbumArtURI(album.getId()) });
        container.setDescription(album.getComment());
    }
    container.setParentID(getRootId());
    container.setTitle(album.getName());
    // TODO: correct artist?
    if (album.getArtist() != null) {
        container.setArtists(getAlbumArtists(album.getArtist()));
    }
    return container;
}
 
Example #6
Source File: RootUpnpProcessor.java    From airsonic with GNU General Public License v3.0 6 votes vote down vote up
public Container createRootContainer() {
    StorageFolder root = new StorageFolder();
    root.setId(DispatchingContentDirectory.CONTAINER_ID_ROOT);
    root.setParentID("-1");

    MediaLibraryStatistics statistics = indexManager.getStatistics();
    // returning large storageUsed values doesn't play nicely with
    // some upnp clients
    //root.setStorageUsed(statistics == null ? 0 : statistics.getTotalLengthInBytes());
    root.setStorageUsed(-1L);
    root.setTitle("Airsonic Media");
    root.setRestricted(true);
    root.setSearchable(true);
    root.setWriteStatus(WriteStatus.NOT_WRITABLE);

    root.setChildCount(6);
    return root;
}
 
Example #7
Source File: FolderBasedContentDirectory.java    From airsonic-advanced with GNU General Public License v3.0 6 votes vote down vote up
private Container createContainer(MediaFile mediaFile) {
    Container container = mediaFile.isAlbum() ? createAlbumContainer(mediaFile) : new MusicAlbum();
    container.setId(CONTAINER_ID_FOLDER_PREFIX + mediaFile.getId());
    container.setTitle(mediaFile.getName());
    List<MediaFile> children = mediaFileService.getChildrenOf(mediaFile, true, true, false);
    container.setChildCount(children.size());

    container.setParentID(CONTAINER_ID_ROOT);
    if (!mediaFileService.isRoot(mediaFile)) {
        MediaFile parent = mediaFileService.getParentOf(mediaFile);
        if (parent != null) {
            container.setParentID(String.valueOf(parent.getId()));
        }
    }
    return container;
}
 
Example #8
Source File: MediaFileUpnpProcessor.java    From airsonic with GNU General Public License v3.0 6 votes vote down vote up
public Container createContainer(MediaFile item) {
    MusicAlbum container = new MusicAlbum();
    if (item.isAlbum()) {
        container.setAlbumArtURIs(new URI[] { getDispatcher().getAlbumProcessor().getAlbumArtURI(item.getId())});

        if (item.getArtist() != null) {
            container.setArtists(getDispatcher().getAlbumProcessor().getAlbumArtists(item.getArtist()));
        }
        container.setDescription(item.getComment());
    }
    container.setId(DispatchingContentDirectory.CONTAINER_ID_FOLDER_PREFIX + DispatchingContentDirectory.SEPARATOR + item.getId());
    container.setTitle(item.getName());
    List<MediaFile> children = getChildren(item);
    container.setChildCount(children.size());

    if (! getMediaFileService().isRoot(item)) {
        MediaFile parent = getMediaFileService().getParentOf(item);
        if (parent != null) {
            container.setParentID(String.valueOf(parent.getId()));
        }
    } else {
        container.setParentID(DispatchingContentDirectory.CONTAINER_ID_FOLDER_PREFIX);
    }
    return container;
}
 
Example #9
Source File: GenreUpnpProcessor.java    From airsonic-advanced with GNU General Public License v3.0 5 votes vote down vote up
public Container createContainer(Genre item, int index) {
    GenreContainer container = new GenreContainer();
    container.setId(getRootId() + DispatchingContentDirectory.SEPARATOR + index);
    container.setParentID(getRootId());
    container.setTitle(item.getName());
    container.setChildCount(item.getAlbumCount());

    return container;
}
 
Example #10
Source File: ContentActivity.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
protected Container createRootContainer(Service service) {
	Container rootContainer = new Container();
	rootContainer.setId("0");
	rootContainer.setTitle("Content Directory on "
			+ service.getDevice().getDisplayString());
	return rootContainer;
}
 
Example #11
Source File: RootUpnpProcessor.java    From airsonic with GNU General Public License v3.0 5 votes vote down vote up
public List<Container> getAllItems() throws Exception {
    ArrayList<Container> allItems = new ArrayList<Container>();
    allItems.add(getDispatchingContentDirectory().getAlbumProcessor().createRootContainer());
    allItems.add(getDispatchingContentDirectory().getArtistProcessor().createRootContainer());
    allItems.add(getDispatchingContentDirectory().getMediaFileProcessor().createRootContainer());
    allItems.add(getDispatchingContentDirectory().getGenreProcessor().createRootContainer());
    allItems.add(getDispatchingContentDirectory().getPlaylistProcessor().createRootContainer());
    allItems.add(getDispatchingContentDirectory().getRecentAlbumProcessor().createRootContainer());
    return allItems;
}
 
Example #12
Source File: ContentBrowseActionCallback.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public ContentBrowseActionCallback(Activity activity, Service service,
		Container container, ArrayList<ContentItem> list, Handler handler) {
	super(service, container.getId(), BrowseFlag.DIRECT_CHILDREN, "*", 0,
			null, new SortCriterion(true, "dc:title"));
	this.activity = activity;
	this.service = service;
	this.container = container;
	this.list = list;
	this.handler = handler;
}
 
Example #13
Source File: ContentItem.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public ContentItem(Container container, Service service, Device device) {
	// TODO Auto-generated constructor stub
	this.device = device;
	this.service = service;
	this.content = container;
	this.id = container.getId();
	this.isContainer = true;
}
 
Example #14
Source File: FolderBasedContentDirectory.java    From subsonic with GNU General Public License v3.0 5 votes vote down vote up
private Container createPlaylistRootContainer() {
    Container container = new StorageFolder();
    container.setId(CONTAINER_ID_PLAYLIST_ROOT);
    container.setTitle("Playlists");

    List<Playlist> playlists = playlistService.getAllPlaylists();
    container.setChildCount(playlists.size());
    container.setParentID(CONTAINER_ID_ROOT);
    return container;
}
 
Example #15
Source File: DIDLContent.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Adds {@link Item} or {@link Container} typed instances, ignores everything else.
 */
public DIDLContent addObject(Object object) {
    if(object instanceof Item) {
    	addItem((Item)object);
    } else if(object instanceof Container) {
    	addContainer((Container)object);
    }
    return this;
}
 
Example #16
Source File: FolderBasedContentDirectory.java    From airsonic-advanced with GNU General Public License v3.0 5 votes vote down vote up
private Container createPlaylistContainer(Playlist playlist) {
    PlaylistContainer container = new PlaylistContainer();
    container.setId(CONTAINER_ID_PLAYLIST_PREFIX + playlist.getId());
    container.setParentID(CONTAINER_ID_PLAYLIST_ROOT);
    container.setTitle(playlist.getName());
    container.setDescription(playlist.getComment());
    container.setChildCount(playlistService.getFilesInPlaylist(playlist.getId()).size());

    return container;
}
 
Example #17
Source File: FolderBasedContentDirectory.java    From airsonic-advanced with GNU General Public License v3.0 5 votes vote down vote up
private Container createPlaylistRootContainer() {
    Container container = new StorageFolder();
    container.setId(CONTAINER_ID_PLAYLIST_ROOT);
    container.setTitle("Playlists");

    List<Playlist> playlists = playlistService.getAllPlaylists();
    container.setChildCount(playlists.size());
    container.setParentID(CONTAINER_ID_ROOT);
    return container;
}
 
Example #18
Source File: FolderBasedContentDirectory.java    From subsonic with GNU General Public License v3.0 5 votes vote down vote up
private Container createAlbumContainer(MediaFile album) throws Exception {
    MusicAlbum container = new MusicAlbum();
    container.setAlbumArtURIs(new URI[]{getAlbumArtUrl(album)});

    // TODO: correct artist?
    if (album.getArtist() != null) {
        container.setArtists(new PersonWithRole[]{new PersonWithRole(album.getArtist())});
    }
    container.setDescription(album.getComment());

    return container;
}
 
Example #19
Source File: ArtistUpnpProcessor.java    From airsonic with GNU General Public License v3.0 5 votes vote down vote up
public Container createContainer(Artist artist) {
    MusicArtist container = new MusicArtist();
    container.setId(getRootId() + DispatchingContentDirectory.SEPARATOR + artist.getId());
    container.setParentID(getRootId());
    container.setTitle(artist.getName());
    container.setChildCount(artist.getAlbumCount());

    return container;
}
 
Example #20
Source File: ContentItem.java    From HPlayer with Apache License 2.0 5 votes vote down vote up
public Container getContainer() {
    if (isContainer) {
        return (Container) didlObject;
    } else {
        return null;
    }
}
 
Example #21
Source File: DIDLContent.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Adds {@link Item} or {@link Container} typed instances, ignores everything else.
 */
public DIDLContent addObject(Object object) {
    if(object instanceof Item) {
    	addItem((Item)object);
    } else if(object instanceof Container) {
    	addContainer((Container)object);
    }
    return this;
}
 
Example #22
Source File: FolderBasedContentDirectory.java    From airsonic with GNU General Public License v3.0 5 votes vote down vote up
private Container createAlbumContainer(MediaFile album) {
    MusicAlbum container = new MusicAlbum();
    container.setAlbumArtURIs(new URI[]{getAlbumArtUrl(album)});

    // TODO: correct artist?
    if (album.getArtist() != null) {
        container.setArtists(new PersonWithRole[]{new PersonWithRole(album.getArtist())});
    }
    container.setDescription(album.getComment());

    return container;
}
 
Example #23
Source File: ContentTree.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
protected static ContentNode createRootNode() {
	// create root container
	Container root = new Container();
	root.setId(ROOT_ID);
	root.setParentID("-1");
	root.setTitle("GNaP MediaServer root directory");
	root.setCreator("GNaP Media Server");
	root.setRestricted(true);
	root.setSearchable(true);
	root.setWriteStatus(WriteStatus.NOT_WRITABLE);
	root.setChildCount(0);
	ContentNode rootNode = new ContentNode(ROOT_ID, root);
	contentMap.put(ROOT_ID, rootNode);
	return rootNode;
}
 
Example #24
Source File: DIDLParser.java    From TVRemoteIME with GNU General Public License v2.0 5 votes vote down vote up
protected Container createContainer(Attributes attributes) {
    Container container = new Container();

    container.setId(attributes.getValue("id"));
    container.setParentID(attributes.getValue("parentID"));

    if ((attributes.getValue("childCount") != null))
        container.setChildCount(Integer.valueOf(attributes.getValue("childCount")));

    try {
        Boolean value = (Boolean)Datatype.Builtin.BOOLEAN.getDatatype().valueOf(
                attributes.getValue("restricted")
        );
        if (value != null)
            container.setRestricted(value);

        value = (Boolean)Datatype.Builtin.BOOLEAN.getDatatype().valueOf(
                attributes.getValue("searchable")
        );
        if (value != null)
            container.setSearchable(value);
    } catch (Exception ex) {
        // Ignore
    }

    return container;
}
 
Example #25
Source File: ContentTree.java    From HPlayer with Apache License 2.0 5 votes vote down vote up
protected static ContentNode createRootNode() {
    // create root container
    Container root = new Container();
    root.setId(ROOT_ID);
    root.setParentID("-1");
    root.setTitle("HPlayer MediaServer root directory");
    root.setCreator("HPlayer Media Server");
    root.setRestricted(true);
    root.setSearchable(true);
    root.setWriteStatus(WriteStatus.NOT_WRITABLE);
    root.setChildCount(0);
    ContentNode rootNode = new ContentNode(ROOT_ID, root);
    contentMap.put(ROOT_ID, rootNode);
    return rootNode;
}
 
Example #26
Source File: GenreUpnpProcessor.java    From airsonic with GNU General Public License v3.0 5 votes vote down vote up
public Container createContainer(Genre item, int index) {
    GenreContainer container = new GenreContainer();
    container.setId(getRootId() + DispatchingContentDirectory.SEPARATOR + index);
    container.setParentID(getRootId());
    container.setTitle(item.getName());
    container.setChildCount(item.getAlbumCount());

    return container;
}
 
Example #27
Source File: ContentItem.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public Container getContainer() {
	if (isContainer)
		return (Container) content;
	else {
		return null;
	}
}
 
Example #28
Source File: ContentItem.java    From DroidDLNA with GNU General Public License v3.0 5 votes vote down vote up
public ContentItem(Container container, Service service) {
	// TODO Auto-generated constructor stub
	this.service = service;
	this.content = container;
	this.id = container.getId();
	this.isContainer = true;
}
 
Example #29
Source File: FolderBasedContentDirectory.java    From airsonic with GNU General Public License v3.0 5 votes vote down vote up
private Container createPlaylistContainer(Playlist playlist) {
    PlaylistContainer container = new PlaylistContainer();
    container.setId(CONTAINER_ID_PLAYLIST_PREFIX + playlist.getId());
    container.setParentID(CONTAINER_ID_PLAYLIST_ROOT);
    container.setTitle(playlist.getName());
    container.setDescription(playlist.getComment());
    container.setChildCount(playlistService.getFilesInPlaylist(playlist.getId()).size());

    return container;
}
 
Example #30
Source File: FolderBasedContentDirectory.java    From airsonic with GNU General Public License v3.0 5 votes vote down vote up
private Container createPlaylistRootContainer() {
    Container container = new StorageFolder();
    container.setId(CONTAINER_ID_PLAYLIST_ROOT);
    container.setTitle("Playlists");

    List<Playlist> playlists = playlistService.getAllPlaylists();
    container.setChildCount(playlists.size());
    container.setParentID(CONTAINER_ID_ROOT);
    return container;
}