org.fourthline.cling.support.model.SortCriterion Java Examples

The following examples show how to use org.fourthline.cling.support.model.SortCriterion. 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 Project: airsonic-advanced   Author: airsonic-advanced   File: GenreUpnpProcessor.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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 Project: airsonic-advanced   Author: airsonic-advanced   File: UpnpContentProcessor.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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 Project: airsonic-advanced   Author: airsonic-advanced   File: UpnpContentProcessor.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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 Project: airsonic-advanced   Author: airsonic-advanced   File: UpnpContentProcessor.java    License: GNU General Public License v3.0 6 votes vote down vote up
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 #5
Source Project: airsonic-advanced   Author: airsonic-advanced   File: RecentAlbumUpnpProcessor.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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 #6
Source Project: TVRemoteIME   Author: kingthy   File: Browse.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param maxResults Can be <code>null</code>, then {@link #getDefaultMaxResults()} is used.
 */
public Browse(Service service, String objectID, BrowseFlag flag,
                            String filter, long firstResult, Long maxResults, SortCriterion... orderBy) {

    super(new ActionInvocation(service.getAction("Browse")));

    log.fine("Creating browse action for object ID: " + objectID);

    getActionInvocation().setInput("ObjectID", objectID);
    getActionInvocation().setInput("BrowseFlag", flag.toString());
    getActionInvocation().setInput("Filter", filter);
    getActionInvocation().setInput("StartingIndex", new UnsignedIntegerFourBytes(firstResult));
    getActionInvocation().setInput("RequestedCount",
            new UnsignedIntegerFourBytes(maxResults == null ? getDefaultMaxResults() : maxResults)
    );
    getActionInvocation().setInput("SortCriteria", SortCriterion.toString(orderBy));
}
 
Example #7
Source Project: TVRemoteIME   Author: kingthy   File: Search.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param maxResults Can be <code>null</code>, then {@link #getDefaultMaxResults()} is used.
 */
public Search(Service service, String containerId, String searchCriteria, String filter,
              long firstResult, Long maxResults, SortCriterion... orderBy) {
    super(new ActionInvocation(service.getAction("Search")));

    log.fine("Creating browse action for container ID: " + containerId);

    getActionInvocation().setInput("ContainerID", containerId);
    getActionInvocation().setInput("SearchCriteria", searchCriteria);
    getActionInvocation().setInput("Filter", filter);
    getActionInvocation().setInput("StartingIndex", new UnsignedIntegerFourBytes(firstResult));
    getActionInvocation().setInput(
            "RequestedCount",
            new UnsignedIntegerFourBytes(maxResults == null ? getDefaultMaxResults() : maxResults)
    );
    getActionInvocation().setInput("SortCriteria", SortCriterion.toString(orderBy));
}
 
Example #8
Source Project: airsonic   Author: airsonic   File: GenreUpnpProcessor.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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 #9
Source Project: airsonic   Author: airsonic   File: UpnpContentProcessor.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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 #10
Source Project: airsonic   Author: airsonic   File: UpnpContentProcessor.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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 #11
Source Project: airsonic   Author: airsonic   File: UpnpContentProcessor.java    License: GNU General Public License v3.0 6 votes vote down vote up
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 #12
Source Project: airsonic   Author: airsonic   File: RecentAlbumUpnpProcessor.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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 #13
Source Project: BeyondUPnP   Author: kevinshine   File: BeyondContentDirectoryService.java    License: Apache License 2.0 6 votes vote down vote up
@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 #14
Source Project: DroidDLNA   Author: offbye   File: Browse.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * @param maxResults Can be <code>null</code>, then {@link #getDefaultMaxResults()} is used.
 */
public Browse(Service service, String objectID, BrowseFlag flag,
                            String filter, long firstResult, Long maxResults, SortCriterion... orderBy) {

    super(new ActionInvocation(service.getAction("Browse")));

    log.fine("Creating browse action for object ID: " + objectID);

    getActionInvocation().setInput("ObjectID", objectID);
    getActionInvocation().setInput("BrowseFlag", flag.toString());
    getActionInvocation().setInput("Filter", filter);
    getActionInvocation().setInput("StartingIndex", new UnsignedIntegerFourBytes(firstResult));
    getActionInvocation().setInput("RequestedCount",
            new UnsignedIntegerFourBytes(maxResults == null ? getDefaultMaxResults() : maxResults)
    );
    getActionInvocation().setInput("SortCriteria", SortCriterion.toString(orderBy));
}
 
Example #15
Source Project: DroidDLNA   Author: offbye   File: Search.java    License: GNU General Public License v3.0 6 votes vote down vote up
/**
 * @param maxResults Can be <code>null</code>, then {@link #getDefaultMaxResults()} is used.
 */
public Search(Service service, String containerId, String searchCriteria, String filter,
              long firstResult, Long maxResults, SortCriterion... orderBy) {
    super(new ActionInvocation(service.getAction("Search")));

    log.fine("Creating browse action for container ID: " + containerId);

    getActionInvocation().setInput("ContainerID", containerId);
    getActionInvocation().setInput("SearchCriteria", searchCriteria);
    getActionInvocation().setInput("Filter", filter);
    getActionInvocation().setInput("StartingIndex", new UnsignedIntegerFourBytes(firstResult));
    getActionInvocation().setInput(
            "RequestedCount",
            new UnsignedIntegerFourBytes(maxResults == null ? getDefaultMaxResults() : maxResults)
    );
    getActionInvocation().setInput("SortCriteria", SortCriterion.toString(orderBy));
}
 
Example #16
Source Project: airsonic-advanced   Author: airsonic-advanced   File: CustomContentDirectory.java    License: GNU General Public License v3.0 5 votes vote down vote up
@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 #17
Source Project: airsonic-advanced   Author: airsonic-advanced   File: AlbumUpnpProcessor.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 #18
Source Project: TVRemoteIME   Author: kingthy   File: AbstractContentDirectoryService.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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 #19
Source Project: airsonic   Author: airsonic   File: CustomContentDirectory.java    License: GNU General Public License v3.0 5 votes vote down vote up
@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 Project: airsonic   Author: airsonic   File: AlbumUpnpProcessor.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 #21
Source Project: subsonic   Author: sindremehus   File: SubsonicContentDirectory.java    License: GNU General Public License v3.0 5 votes vote down vote up
@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 #22
Source Project: subsonic   Author: sindremehus   File: FolderBasedContentDirectory.java    License: GNU General Public License v3.0 5 votes vote down vote up
@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 #23
Source Project: BeyondUPnP   Author: kevinshine   File: ContentContainerActivity.java    License: Apache License 2.0 5 votes vote down vote up
private void loadContent() {
    SystemManager systemManager = SystemManager.getInstance();
    Device device = null;
    try {
        device = systemManager.getRegistry().getDevice(new UDN(mIdentifierString), false);
    } catch (NullPointerException e) {
        Log.e(TAG, "Get device error.");
    }

    if (device != null) {
        //Get cds to browse children directories.
        Service contentDeviceService = device.findService(SystemManager.CONTENT_DIRECTORY_SERVICE);
        //Execute Browse action and init list view
        systemManager.getControlPoint().execute(new Browse(contentDeviceService, mObjectId, BrowseFlag.DIRECT_CHILDREN, "*", 0,
                null, new SortCriterion(true, "dc:title")) {
            @Override
            public void received(ActionInvocation actionInvocation, DIDLContent didl) {
                Message msg = Message.obtain(handler,ADD_OBJECTS,didl);
                msg.sendToTarget();
            }

            @Override
            public void updateStatus(Status status) {
            }

            @Override
            public void failure(ActionInvocation invocation, UpnpResponse operation, String defaultMsg) {
            }
        });
    }
}
 
Example #24
Source Project: DroidDLNA   Author: offbye   File: AbstractContentDirectoryService.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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 #25
Source Project: DroidDLNA   Author: offbye   File: ContentBrowseActionCallback.java    License: 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 #26
Source Project: DroidDLNA   Author: offbye   File: ContentDirectoryService.java    License: GNU General Public License v3.0 5 votes vote down vote up
@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 #27
Source Project: HPlayer   Author: hezhubo   File: ContentDirectoryService.java    License: Apache License 2.0 4 votes vote down vote up
@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 #28
Source Project: HPlayer   Author: hezhubo   File: ContentBrowseActionCallback.java    License: Apache License 2.0 4 votes vote down vote up
public ContentBrowseActionCallback(Service service, Container container, OnReceiveListener listener) {
    super(service, container.getId(), BrowseFlag.DIRECT_CHILDREN, "*", 0,
            null, new SortCriterion(true, "dc:title"));
    this.service = service;
    this.onReceiveListener = listener;
}
 
Example #29
Source Project: HPlayer   Author: hezhubo   File: ContentBrowseActionCallback.java    License: Apache License 2.0 4 votes vote down vote up
public ContentBrowseActionCallback(Service service, String id, OnReceiveListener listener) {
    super(service, id, BrowseFlag.DIRECT_CHILDREN, "*", 0,
            null, new SortCriterion(true, "dc:title"));
    this.service = service;
    this.onReceiveListener = listener;
}
 
Example #30
Source Project: DroidDLNA   Author: offbye   File: ContentDirectoryService.java    License: GNU General Public License v3.0 4 votes vote down vote up
@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());
	}
}