org.fourthline.cling.support.model.item.Item Java Examples
The following examples show how to use
org.fourthline.cling.support.model.item.Item.
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: MediaFileUpnpProcessor.java From airsonic-advanced with GNU General Public License v3.0 | 6 votes |
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 #2
Source File: DispatchingContentDirectory.java From airsonic with GNU General Public License v3.0 | 6 votes |
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 #3
Source File: MediaFileUpnpProcessor.java From airsonic with GNU General Public License v3.0 | 6 votes |
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 #4
Source File: FolderBasedContentDirectory.java From airsonic with GNU General Public License v3.0 | 6 votes |
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 #5
Source File: FolderBasedContentDirectory.java From subsonic with GNU General Public License v3.0 | 6 votes |
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 #6
Source File: DIDLParser.java From TVRemoteIME with GNU General Public License v2.0 | 6 votes |
@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 File: DIDLParser.java From TVRemoteIME with GNU General Public License v2.0 | 6 votes |
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 #8
Source File: DIDLParser.java From TVRemoteIME with GNU General Public License v2.0 | 6 votes |
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 #9
Source File: ContentContainerActivity.java From BeyondUPnP with Apache License 2.0 | 6 votes |
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 #10
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 #11
Source File: DIDLParser.java From DroidDLNA with GNU General Public License v3.0 | 6 votes |
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 #12
Source File: DIDLParser.java From DroidDLNA with GNU General Public License v3.0 | 6 votes |
@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 #13
Source File: FolderBasedContentDirectory.java From airsonic-advanced with GNU General Public License v3.0 | 6 votes |
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 #14
Source File: DispatchingContentDirectory.java From airsonic-advanced with GNU General Public License v3.0 | 6 votes |
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 #15
Source File: DIDLParser.java From DroidDLNA with GNU General Public License v3.0 | 6 votes |
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 #16
Source File: MediaResourceDao.java From BeyondUPnP with Apache License 2.0 | 5 votes |
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 #17
Source File: Container.java From TVRemoteIME with GNU General Public License v2.0 | 5 votes |
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 #18
Source File: DIDLParser.java From TVRemoteIME with GNU General Public License v2.0 | 5 votes |
@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 #19
Source File: MusicAlbum.java From TVRemoteIME with GNU General Public License v2.0 | 5 votes |
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 #20
Source File: UpnpUtil.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
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 #21
Source File: ContentItem.java From HPlayer with Apache License 2.0 | 5 votes |
public Item getItem() { if (!isContainer) { return (Item) didlObject; } else { return null; } }
Example #22
Source File: UpnpUtil.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
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 File: UpnpUtil.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
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 #24
Source File: MediaResourceDao.java From BeyondUPnP with Apache License 2.0 | 5 votes |
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 #25
Source File: ContentItem.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
public ContentItem(Item item, Service service) { // TODO Auto-generated constructor stub this.service = service; this.content = item; this.id = item.getId(); this.isContainer = false; }
Example #26
Source File: DIDLParser.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
@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 #27
Source File: DIDLContent.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
/** * 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 File: PhotoAlbum.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
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 File: MusicAlbum.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
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 File: Container.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
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; }