Java Code Examples for org.fourthline.cling.support.model.item.Item

The following examples show how to use org.fourthline.cling.support.model.item.Item. These examples are extracted from open source projects. 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: DispatchingContentDirectory.java    License: GNU General Public License v3.0 6 votes vote down vote up
public Item createItem(MediaFile song) {
    MediaFile parent = mediaFileService.getParentOf(song);
    MusicTrack item = new MusicTrack();
    item.setId(String.valueOf(song.getId()));
    item.setParentID(String.valueOf(parent.getId()));
    item.setTitle(song.getTitle());
    item.setAlbum(song.getAlbumName());
    if (song.getArtist() != null) {
        item.setArtists(new PersonWithRole[]{new PersonWithRole(song.getArtist())});
    }
    Integer year = song.getYear();
    if (year != null) {
        item.setDate(year + "-01-01");
    }
    item.setOriginalTrackNumber(song.getTrackNumber());
    if (song.getGenre() != null) {
        item.setGenres(new String[]{song.getGenre()});
    }
    item.setResources(Arrays.asList(createResourceForSong(song)));
    item.setDescription(song.getComment());
    item.addProperty(new DIDLObject.Property.UPNP.ALBUM_ART_URI(getAlbumArtUrl(parent.getId())));

    return item;
}
 
Example #2
Source Project: airsonic-advanced   Author: airsonic-advanced   File: MediaFileUpnpProcessor.java    License: GNU General Public License v3.0 6 votes vote down vote up
public Item createItem(MediaFile song) {
    MediaFile parent = getMediaFileService().getParentOf(song);
    MusicTrack item = new MusicTrack();
    item.setId(String.valueOf(song.getId()));
    item.setParentID(String.valueOf(parent.getId()));
    item.setTitle(song.getTitle());
    item.setAlbum(song.getAlbumName());
    if (song.getArtist() != null) {
        item.setArtists(getDispatcher().getAlbumProcessor().getAlbumArtists(song.getArtist()));
    }
    Integer year = song.getYear();
    if (year != null) {
        item.setDate(year + "-01-01");
    }
    item.setOriginalTrackNumber(song.getTrackNumber());
    if (song.getGenre() != null) {
        item.setGenres(new String[]{song.getGenre()});
    }
    item.setResources(Arrays.asList(getDispatcher().createResourceForSong(song)));
    item.setDescription(song.getComment());
    item.addProperty(new DIDLObject.Property.UPNP.ALBUM_ART_URI(getDispatcher().getAlbumProcessor().getAlbumArtURI(parent.getId())));

    return item;
}
 
Example #3
Source Project: airsonic-advanced   Author: airsonic-advanced   File: FolderBasedContentDirectory.java    License: GNU General Public License v3.0 6 votes vote down vote up
private Item createItem(MediaFile song) {
    MediaFile parent = mediaFileService.getParentOf(song);
    MusicTrack item = new MusicTrack();
    item.setId(String.valueOf(song.getId()));
    item.setParentID(String.valueOf(parent.getId()));
    item.setTitle(song.getTitle());
    item.setAlbum(song.getAlbumName());
    if (song.getArtist() != null) {
        item.setArtists(new PersonWithRole[]{new PersonWithRole(song.getArtist())});
    }
    Integer year = song.getYear();
    if (year != null) {
        item.setDate(year + "-01-01");
    }
    item.setOriginalTrackNumber(song.getTrackNumber());
    if (song.getGenre() != null) {
        item.setGenres(new String[]{song.getGenre()});
    }
    item.setResources(Arrays.asList(createResourceForSong(song)));
    item.setDescription(song.getComment());
    item.addProperty(new DIDLObject.Property.UPNP.ALBUM_ART_URI(getAlbumArtUrl(parent)));

    return item;
}
 
Example #4
Source Project: TVRemoteIME   Author: kingthy   File: DIDLParser.java    License: GNU General Public License v2.0 6 votes vote down vote up
protected Item createItem(Attributes attributes) {
    Item item = new Item();

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

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

    } catch (Exception ex) {
        // Ignore
    }

    if ((attributes.getValue("refID") != null))
        item.setRefID(attributes.getValue("refID"));

    return item;
}
 
Example #5
Source Project: TVRemoteIME   Author: kingthy   File: DIDLParser.java    License: GNU General Public License v2.0 6 votes vote down vote up
protected void generateRoot(DIDLContent content, Document descriptor, boolean nestedItems) {
    Element rootElement = descriptor.createElementNS(DIDLContent.NAMESPACE_URI, "DIDL-Lite");
    descriptor.appendChild(rootElement);

    // rootElement.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:didl", DIDLContent.NAMESPACE_URI);
    rootElement.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:upnp", DIDLObject.Property.UPNP.NAMESPACE.URI);
    rootElement.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:dc", DIDLObject.Property.DC.NAMESPACE.URI);
    rootElement.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:sec", DIDLObject.Property.SEC.NAMESPACE.URI);

    for (Container container : content.getContainers()) {
        if (container == null) continue;
        generateContainer(container, descriptor, rootElement, nestedItems);
    }

    for (Item item : content.getItems()) {
        if (item == null) continue;
        generateItem(item, descriptor, rootElement);
    }

    for (DescMeta descMeta : content.getDescMetadata()) {
        if (descMeta == null) continue;
        generateDescMetadata(descMeta, descriptor, rootElement);
    }
}
 
Example #6
Source Project: TVRemoteIME   Author: kingthy   File: DIDLParser.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
    super.startElement(uri, localName, qName, attributes);

    if (!DIDLContent.NAMESPACE_URI.equals(uri)) return;

    if (localName.equals("container")) {

        Container container = createContainer(attributes);
        getInstance().addContainer(container);
        createContainerHandler(container, this);

    } else if (localName.equals("item")) {

        Item item = createItem(attributes);
        getInstance().addItem(item);
        createItemHandler(item, this);

    } else if (localName.equals("desc")) {

        DescMeta desc = createDescMeta(attributes);
        getInstance().addDescMetadata(desc);
        createDescMetaHandler(desc, this);

    }
}
 
Example #7
Source Project: airsonic   Author: airsonic   File: DispatchingContentDirectory.java    License: GNU General Public License v3.0 6 votes vote down vote up
public Item createItem(MediaFile song) {
    MediaFile parent = mediaFileService.getParentOf(song);
    MusicTrack item = new MusicTrack();
    item.setId(String.valueOf(song.getId()));
    item.setParentID(String.valueOf(parent.getId()));
    item.setTitle(song.getTitle());
    item.setAlbum(song.getAlbumName());
    if (song.getArtist() != null) {
        item.setArtists(new PersonWithRole[]{new PersonWithRole(song.getArtist())});
    }
    Integer year = song.getYear();
    if (year != null) {
        item.setDate(year + "-01-01");
    }
    item.setOriginalTrackNumber(song.getTrackNumber());
    if (song.getGenre() != null) {
        item.setGenres(new String[]{song.getGenre()});
    }
    item.setResources(Arrays.asList(createResourceForSong(song)));
    item.setDescription(song.getComment());
    item.addProperty(new DIDLObject.Property.UPNP.ALBUM_ART_URI(getAlbumArtUrl(parent.getId())));

    return item;
}
 
Example #8
Source Project: airsonic   Author: airsonic   File: MediaFileUpnpProcessor.java    License: GNU General Public License v3.0 6 votes vote down vote up
public Item createItem(MediaFile song) {
    MediaFile parent = getMediaFileService().getParentOf(song);
    MusicTrack item = new MusicTrack();
    item.setId(String.valueOf(song.getId()));
    item.setParentID(String.valueOf(parent.getId()));
    item.setTitle(song.getTitle());
    item.setAlbum(song.getAlbumName());
    if (song.getArtist() != null) {
        item.setArtists(getDispatcher().getAlbumProcessor().getAlbumArtists(song.getArtist()));
    }
    Integer year = song.getYear();
    if (year != null) {
        item.setDate(year + "-01-01");
    }
    item.setOriginalTrackNumber(song.getTrackNumber());
    if (song.getGenre() != null) {
        item.setGenres(new String[]{song.getGenre()});
    }
    item.setResources(Arrays.asList(getDispatcher().createResourceForSong(song)));
    item.setDescription(song.getComment());
    item.addProperty(new DIDLObject.Property.UPNP.ALBUM_ART_URI(getDispatcher().getAlbumProcessor().getAlbumArtURI(parent.getId())));

    return item;
}
 
Example #9
Source Project: airsonic   Author: airsonic   File: FolderBasedContentDirectory.java    License: GNU General Public License v3.0 6 votes vote down vote up
private Item createItem(MediaFile song) {
    MediaFile parent = mediaFileService.getParentOf(song);
    MusicTrack item = new MusicTrack();
    item.setId(String.valueOf(song.getId()));
    item.setParentID(String.valueOf(parent.getId()));
    item.setTitle(song.getTitle());
    item.setAlbum(song.getAlbumName());
    if (song.getArtist() != null) {
        item.setArtists(new PersonWithRole[]{new PersonWithRole(song.getArtist())});
    }
    Integer year = song.getYear();
    if (year != null) {
        item.setDate(year + "-01-01");
    }
    item.setOriginalTrackNumber(song.getTrackNumber());
    if (song.getGenre() != null) {
        item.setGenres(new String[]{song.getGenre()});
    }
    item.setResources(Arrays.asList(createResourceForSong(song)));
    item.setDescription(song.getComment());
    item.addProperty(new DIDLObject.Property.UPNP.ALBUM_ART_URI(getAlbumArtUrl(parent)));

    return item;
}
 
Example #10
Source Project: subsonic   Author: sindremehus   File: FolderBasedContentDirectory.java    License: GNU General Public License v3.0 6 votes vote down vote up
private Item createItem(MediaFile song) throws Exception {
    MediaFile parent = mediaFileService.getParentOf(song);
    MusicTrack item = new MusicTrack();
    item.setId(String.valueOf(song.getId()));
    item.setParentID(String.valueOf(parent.getId()));
    item.setTitle(song.getTitle());
    item.setAlbum(song.getAlbumName());
    if (song.getArtist() != null) {
        item.setArtists(new PersonWithRole[]{new PersonWithRole(song.getArtist())});
    }
    Integer year = song.getYear();
    if (year != null) {
        item.setDate(year + "-01-01");
    }
    item.setOriginalTrackNumber(song.getTrackNumber());
    if (song.getGenre() != null) {
        item.setGenres(new String[]{song.getGenre()});
    }
    item.setResources(Arrays.asList(createResourceForSong(song)));
    item.setDescription(song.getComment());
    item.addProperty(new DIDLObject.Property.UPNP.ALBUM_ART_URI(getAlbumArtUrl(parent)));

    return item;
}
 
Example #11
Source Project: BeyondUPnP   Author: kevinshine   File: ContentContainerActivity.java    License: Apache License 2.0 6 votes vote down vote up
private void playItem(Item item){
    if (item == null) return;

    Res res = item.getFirstResource();
    String uri = res.getValue();

    DIDLContent content = new DIDLContent();
    content.addItem(item);
    DIDLParser didlParser = new DIDLParser();
    String metadata = null;
    try {
        metadata = didlParser.generate(content);
    } catch (Exception e) {
        //ignore
    }
    //Log.d(TAG,"Item metadata:" + metadata);
    //Play on the selected device.
    PlaybackCommand.playNewItem(uri,metadata);
}
 
Example #12
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 #13
Source Project: DroidDLNA   Author: offbye   File: DIDLParser.java    License: GNU General Public License v3.0 6 votes vote down vote up
protected Item createItem(Attributes attributes) {
    Item item = new Item();

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

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

    } catch (Exception ex) {
        // Ignore
    }

    if ((attributes.getValue("refID") != null))
        item.setRefID(attributes.getValue("refID"));

    return item;
}
 
Example #14
Source Project: DroidDLNA   Author: offbye   File: DIDLParser.java    License: GNU General Public License v3.0 6 votes vote down vote up
protected void generateRoot(DIDLContent content, Document descriptor, boolean nestedItems) {
    Element rootElement = descriptor.createElementNS(DIDLContent.NAMESPACE_URI, "DIDL-Lite");
    descriptor.appendChild(rootElement);

    // rootElement.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:didl", DIDLContent.NAMESPACE_URI);
    rootElement.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:upnp", DIDLObject.Property.UPNP.NAMESPACE.URI);
    rootElement.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:dc", DIDLObject.Property.DC.NAMESPACE.URI);
    rootElement.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:sec", DIDLObject.Property.SEC.NAMESPACE.URI);

    for (Container container : content.getContainers()) {
        if (container == null) continue;
        generateContainer(container, descriptor, rootElement, nestedItems);
    }

    for (Item item : content.getItems()) {
        if (item == null) continue;
        generateItem(item, descriptor, rootElement);
    }

    for (DescMeta descMeta : content.getDescMetadata()) {
        if (descMeta == null) continue;
        generateDescMetadata(descMeta, descriptor, rootElement);
    }
}
 
Example #15
Source Project: DroidDLNA   Author: offbye   File: DIDLParser.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
    super.startElement(uri, localName, qName, attributes);

    if (!DIDLContent.NAMESPACE_URI.equals(uri)) return;

    if (localName.equals("container")) {

        Container container = createContainer(attributes);
        getInstance().addContainer(container);
        createContainerHandler(container, this);

    } else if (localName.equals("item")) {

        Item item = createItem(attributes);
        getInstance().addItem(item);
        createItemHandler(item, this);

    } else if (localName.equals("desc")) {

        DescMeta desc = createDescMeta(attributes);
        getInstance().addDescMetadata(desc);
        createDescMetaHandler(desc, this);

    }
}
 
Example #16
Source Project: TVRemoteIME   Author: kingthy   File: DIDLContent.java    License: 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 #17
Source Project: TVRemoteIME   Author: kingthy   File: PhotoAlbum.java    License: GNU General Public License v2.0 5 votes vote down vote up
public Photo[] getPhotos() {
    List<Photo> list = new ArrayList();
    for (Item item : getItems()) {
        if (item instanceof Photo) list.add((Photo)item);
    }
    return list.toArray(new Photo[list.size()]);
}
 
Example #18
Source Project: TVRemoteIME   Author: kingthy   File: MusicAlbum.java    License: GNU General Public License v2.0 5 votes vote down vote up
public MusicTrack[] getMusicTracks() {
    List<MusicTrack> list = new ArrayList();
    for (Item item : getItems()) {
        if (item instanceof MusicTrack) list.add((MusicTrack)item);
    }
    return list.toArray(new MusicTrack[list.size()]);
}
 
Example #19
Source Project: TVRemoteIME   Author: kingthy   File: Container.java    License: GNU General Public License v2.0 5 votes vote down vote up
public Container(String id, String parentID, String title, String creator, boolean restricted, WriteStatus writeStatus, Class clazz, List<Res> resources, List<Property> properties, List<DescMeta> descMetadata, Integer childCount, boolean searchable, List<Class> createClasses, List<Class> searchClasses, List<Item> items) {
    super(id, parentID, title, creator, restricted, writeStatus, clazz, resources, properties, descMetadata);
    this.childCount = childCount;
    this.searchable = searchable;
    this.createClasses = createClasses;
    this.searchClasses = searchClasses;
    this.items = items;
}
 
Example #20
Source Project: TVRemoteIME   Author: kingthy   File: DIDLParser.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
    super.startElement(uri, localName, qName, attributes);

    if (!DIDLContent.NAMESPACE_URI.equals(uri)) return;

    if (localName.equals("item")) {

        Item item = createItem(attributes);
        getInstance().addItem(item);
        createItemHandler(item, this);

    } else if (localName.equals("desc")) {

        DescMeta desc = createDescMeta(attributes);
        getInstance().addDescMetadata(desc);
        createDescMetaHandler(desc, this);

    } else if (localName.equals("res")) {

        Res res = createResource(attributes);
        if (res != null) {
            getInstance().addResource(res);
            createResHandler(res, this);
        }

    }

    // We do NOT support recursive container embedded in container! The schema allows it
    // but the spec doesn't:
    //
    // Section 2.8.3: Incremental navigation i.e. the full hierarchy is never returned
    // in one call since this is likely to flood the resources available to the control
    // point (memory, network bandwidth, etc.).
}
 
Example #21
Source Project: TVRemoteIME   Author: kingthy   File: UpnpUtil.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static boolean isAudioItem(Item item) {
    // TODO zxt need check?
    String objectClass = item.getId();
    if (objectClass != null && objectClass.contains(DLNA_OBJECTCLASS_MUSICID)) {
        return true;
    }
    return false;
}
 
Example #22
Source Project: TVRemoteIME   Author: kingthy   File: UpnpUtil.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static boolean isVideoItem(Item item) {
    // TODO zxt need check?
    String objectClass = item.getId();
    if (objectClass != null && objectClass.contains(DLNA_OBJECTCLASS_VIDEOID)) {
        return true;
    }
    return false;
}
 
Example #23
Source Project: TVRemoteIME   Author: kingthy   File: UpnpUtil.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static boolean isPictureItem(Item item) {
    // TODO zxt need check?
    String objectClass = item.getId();
    if (objectClass != null && objectClass.contains(DLNA_OBJECTCLASS_PHOTOID)) {
        return true;
    }
    return false;
}
 
Example #24
Source Project: HPlayer   Author: hezhubo   File: ContentItem.java    License: Apache License 2.0 5 votes vote down vote up
public Item getItem() {
    if (!isContainer) {
        return (Item) didlObject;
    } else {
        return null;
    }
}
 
Example #25
Source Project: BeyondUPnP   Author: kevinshine   File: MediaResourceDao.java    License: Apache License 2.0 5 votes vote down vote up
public static List<Item> getAudioList(String serverUrl, String parentId) {
    List<Item> items = new ArrayList<>();

    //Query all track,add to items
    Cursor c = BeyondApplication.getApplication().getContentResolver()
            .query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, null, null, null, MediaStore.Audio.Media.TITLE);
    c.moveToFirst();
    while (!c.isAfterLast()) {
        long id = c.getLong(c.getColumnIndex(MediaStore.Audio.Media._ID));
        String title = c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.Media.TITLE));
        String creator = c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.Media.ARTIST));
        String album = c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.Media.ALBUM));

        String data = c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA));
        //Remove SDCard path
        data = data.replaceFirst(storageDir, "");
        //Replace file name by "id.ext"
        String fileName = data.substring(data.lastIndexOf(File.separator));
        String ext = fileName.substring(fileName.lastIndexOf("."));
        data = data.replace(fileName, File.separator + id + ext);

        String mimeType = c.getString(c.getColumnIndexOrThrow(MediaStore.Audio.Media.MIME_TYPE));
        long size = c.getLong(c.getColumnIndexOrThrow(MediaStore.Audio.Media.SIZE));
        long duration = c.getLong(c.getColumnIndexOrThrow(MediaStore.Audio.Media.DURATION));
        //Get duration string
        String durationStr = ModelUtil.toTimeString(duration);

        //Compose audio url
        String url = serverUrl + File.separator + "audio" + File.separator + data;
        Res res = new Res(mimeType, size, durationStr, null, url);

        items.add(new MusicTrack(String.valueOf(id), parentId, title, creator, album, new PersonWithRole(creator), res));

        c.moveToNext();
    }

    return items;
}
 
Example #26
Source Project: BeyondUPnP   Author: kevinshine   File: MediaResourceDao.java    License: Apache License 2.0 5 votes vote down vote up
public static List<Item> getVideoList(String serverUrl, String parentId) {
    List<Item> items = new ArrayList<>();

    Cursor c = BeyondApplication.getApplication().getContentResolver()
            .query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, null, null, null, MediaStore.Video.Media.TITLE);
    c.moveToFirst();
    while (!c.isAfterLast()) {
        long id = c.getLong(c.getColumnIndex(MediaStore.Audio.Media._ID));
        String title = c.getString(c.getColumnIndexOrThrow(MediaStore.Video.Media.TITLE));
        String creator = c.getString(c.getColumnIndexOrThrow(MediaStore.Video.Media.ARTIST));

        String data = c.getString(c.getColumnIndexOrThrow(MediaStore.Video.Media.DATA));
        //Remove SDCard path
        data = data.replaceFirst(storageDir, "");
        //Replace file name by "id.ext"
        String fileName = data.substring(data.lastIndexOf(File.separator));
        String ext = fileName.substring(fileName.lastIndexOf("."));
        data = data.replace(fileName, File.separator + id + ext);

        String mimeType = c.getString(c.getColumnIndexOrThrow(MediaStore.Video.Media.MIME_TYPE));
        long size = c.getLong(c.getColumnIndexOrThrow(MediaStore.Video.Media.SIZE));
        long duration = c.getLong(c.getColumnIndexOrThrow(MediaStore.Video.Media.DURATION));
        //Get duration string
        String durationStr = ModelUtil.toTimeString(duration);

        //Compose audio url
        String url = serverUrl + File.separator + "video" + File.separator + data;
        Res res = new Res(mimeType, size, durationStr, null, url);

        items.add(new Movie(String.valueOf(id), parentId, title, creator, res));

        c.moveToNext();
    }

    return items;
}
 
Example #27
Source Project: DroidDLNA   Author: offbye   File: DIDLContent.java    License: 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 #28
Source Project: DroidDLNA   Author: offbye   File: PhotoAlbum.java    License: GNU General Public License v3.0 5 votes vote down vote up
public Photo[] getPhotos() {
    List<Photo> list = new ArrayList();
    for (Item item : getItems()) {
        if (item instanceof Photo) list.add((Photo)item);
    }
    return list.toArray(new Photo[list.size()]);
}
 
Example #29
Source Project: DroidDLNA   Author: offbye   File: MusicAlbum.java    License: GNU General Public License v3.0 5 votes vote down vote up
public MusicTrack[] getMusicTracks() {
    List<MusicTrack> list = new ArrayList();
    for (Item item : getItems()) {
        if (item instanceof MusicTrack) list.add((MusicTrack)item);
    }
    return list.toArray(new MusicTrack[list.size()]);
}
 
Example #30
Source Project: DroidDLNA   Author: offbye   File: Container.java    License: GNU General Public License v3.0 5 votes vote down vote up
public Container(String id, String parentID, String title, String creator, boolean restricted, WriteStatus writeStatus, Class clazz, List<Res> resources, List<Property> properties, List<DescMeta> descMetadata, Integer childCount, boolean searchable, List<Class> createClasses, List<Class> searchClasses, List<Item> items) {
    super(id, parentID, title, creator, restricted, writeStatus, clazz, resources, properties, descMetadata);
    this.childCount = childCount;
    this.searchable = searchable;
    this.createClasses = createClasses;
    this.searchClasses = searchClasses;
    this.items = items;
}