Java Code Examples for org.fourthline.cling.support.model.container.Container#setParentID()

The following examples show how to use org.fourthline.cling.support.model.container.Container#setParentID() . 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 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 2
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 3
Source File: FolderBasedContentDirectory.java    From subsonic with GNU General Public License v3.0 6 votes vote down vote up
private Container createContainer(MediaFile mediaFile) throws Exception {
    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: UpnpContentProcessor.java    From airsonic-advanced with GNU General Public License v3.0 5 votes vote down vote up
public Container createRootContainer() throws Exception {
    Container container = new StorageFolder();
    container.setId(getRootId());
    container.setTitle(getRootTitle());

    int childCount = getAllItemsSize();
    container.setChildCount(childCount);
    container.setParentID(DispatchingContentDirectory.CONTAINER_ID_ROOT);
    return container;
}
 
Example 5
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 6
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 7
Source File: UpnpContentProcessor.java    From airsonic with GNU General Public License v3.0 5 votes vote down vote up
public Container createRootContainer() throws Exception {
    Container container = new StorageFolder();
    container.setId(getRootId());
    container.setTitle(getRootTitle());

    int childCount = getAllItemsSize();
    container.setChildCount(childCount);
    container.setParentID(DispatchingContentDirectory.CONTAINER_ID_ROOT);
    return container;
}
 
Example 8
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;
}
 
Example 9
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 10
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 11
Source File: DIDLParser.java    From DroidDLNA with GNU General Public License v3.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 12
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 13
Source File: GenerateContentTask.java    From HPlayer with Apache License 2.0 4 votes vote down vote up
/**
     * 添加视频
     */
    private void addVideoContent(Context context, ContentNode rootNode) {

        Container videoContainer = new Container();
        videoContainer.setClazz(new DIDLObject.Class("object.container"));
        videoContainer.setId(ContentTree.VIDEO_ID);
        videoContainer.setParentID(ContentTree.ROOT_ID);
        videoContainer.setTitle("Videos");
        videoContainer.setRestricted(true);
        videoContainer.setWriteStatus(WriteStatus.NOT_WRITABLE);
        videoContainer.setChildCount(0);

        rootNode.getContainer().addContainer(videoContainer);
        rootNode.getContainer().setChildCount(
                rootNode.getContainer().getChildCount() + 1);
        ContentTree.addNode(ContentTree.VIDEO_ID, new ContentNode(
                ContentTree.VIDEO_ID, videoContainer));

        Cursor cursor = context.getContentResolver()
                .query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
                        null, null, null, null);
        if (cursor == null) {
            return;
        }
        while (cursor.moveToNext()) {
            String id = ContentTree.VIDEO_PREFIX
                    + cursor.getInt(cursor.getColumnIndex(MediaStore.Video.Media._ID));
            String title = cursor.getString(cursor
                    .getColumnIndexOrThrow(MediaStore.Video.Media.TITLE));
            String creator = cursor.getString(cursor
                    .getColumnIndexOrThrow(MediaStore.Video.Media.ARTIST));
            String filePath = cursor.getString(cursor
                    .getColumnIndexOrThrow(MediaStore.Video.Media.DATA));
            String mimeType = cursor.getString(cursor
                    .getColumnIndexOrThrow(MediaStore.Video.Media.MIME_TYPE));
            long size = cursor.getLong(cursor
                    .getColumnIndexOrThrow(MediaStore.Video.Media.SIZE));
            long duration = cursor.getLong(cursor
                    .getColumnIndexOrThrow(MediaStore.Video.Media.DURATION));
            String resolution = cursor.getString(cursor
                    .getColumnIndexOrThrow(MediaStore.Video.Media.RESOLUTION));
            Res res = new Res(new MimeType(mimeType.substring(0, mimeType.indexOf('/')),
                    mimeType.substring(mimeType.indexOf('/') + 1)), size,
                    "http://" + address + "/" + id);
            res.setDuration(duration / (1000 * 60 * 60) + ":"
                    + (duration % (1000 * 60 * 60)) / (1000 * 60) + ":"
                    + (duration % (1000 * 60)) / 1000);
            res.setResolution(resolution);

            VideoItem videoItem = new VideoItem(id, ContentTree.VIDEO_ID, title, creator, res);
            videoContainer.addItem(videoItem);
            videoContainer.setChildCount(videoContainer.getChildCount() + 1);
            ContentTree.addNode(id, new ContentNode(id, videoItem, filePath));

//            Log.d(TAG, "added video item " + title + "from " + filePath);
        }

        cursor.close();
    }