org.fourthline.cling.support.model.item.MusicTrack Java Examples
The following examples show how to use
org.fourthline.cling.support.model.item.MusicTrack.
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: 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 #3
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 #4
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 #5
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 #6
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 #7
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 #8
Source File: MusicAlbum.java From DroidDLNA with GNU General Public License v3.0 | 5 votes |
public void addMusicTracks(MusicTrack[] musicTracks) { if (musicTracks != null) { for (MusicTrack musicTrack : musicTracks) { musicTrack.setAlbum(getTitle()); addItem(musicTrack); } } }
Example #9
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 #10
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 #11
Source File: MusicAlbum.java From TVRemoteIME with GNU General Public License v2.0 | 5 votes |
public void addMusicTracks(MusicTrack[] musicTracks) { if (musicTracks != null) { for (MusicTrack musicTrack : musicTracks) { musicTrack.setAlbum(getTitle()); addItem(musicTrack); } } }
Example #12
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 #13
Source File: MusicAlbum.java From TVRemoteIME with GNU General Public License v2.0 | 4 votes |
public MusicAlbum(String id, Container parent, String title, String creator, Integer childCount) { this(id, parent.getId(), title, creator, childCount, new ArrayList<MusicTrack>()); }
Example #14
Source File: DIDLContent.java From TVRemoteIME with GNU General Public License v2.0 | 4 votes |
protected List<Item> replaceGenericItems(List<Item> genericItems) { List<Item> specificItems = new ArrayList(); for (Item genericItem : genericItems) { String genericType = genericItem.getClazz().getValue(); if (AudioItem.CLASS.getValue().equals(genericType)) { specificItems.add(new AudioItem(genericItem)); } else if (MusicTrack.CLASS.getValue().equals(genericType)) { specificItems.add(new MusicTrack(genericItem)); } else if (AudioBook.CLASS.getValue().equals(genericType)) { specificItems.add(new AudioBook(genericItem)); } else if (AudioBroadcast.CLASS.getValue().equals(genericType)) { specificItems.add(new AudioBroadcast(genericItem)); } else if (VideoItem.CLASS.getValue().equals(genericType)) { specificItems.add(new VideoItem(genericItem)); } else if (Movie.CLASS.getValue().equals(genericType)) { specificItems.add(new Movie(genericItem)); } else if (VideoBroadcast.CLASS.getValue().equals(genericType)) { specificItems.add(new VideoBroadcast(genericItem)); } else if (MusicVideoClip.CLASS.getValue().equals(genericType)) { specificItems.add(new MusicVideoClip(genericItem)); } else if (ImageItem.CLASS.getValue().equals(genericType)) { specificItems.add(new ImageItem(genericItem)); } else if (Photo.CLASS.getValue().equals(genericType)) { specificItems.add(new Photo(genericItem)); } else if (PlaylistItem.CLASS.getValue().equals(genericType)) { specificItems.add(new PlaylistItem(genericItem)); } else if (TextItem.CLASS.getValue().equals(genericType)) { specificItems.add(new TextItem(genericItem)); } else { specificItems.add(genericItem); } } return specificItems; }
Example #15
Source File: MusicAlbum.java From TVRemoteIME with GNU General Public License v2.0 | 4 votes |
public void addMusicTracks(List<MusicTrack> musicTracks) { addMusicTracks(musicTracks.toArray(new MusicTrack[musicTracks.size()])); }
Example #16
Source File: GenerateContentTask.java From HPlayer with Apache License 2.0 | 4 votes |
/** * 添加音频 */ private void addAudioContent(Context context, ContentNode rootNode) { Container audioContainer = new Container(ContentTree.AUDIO_ID, ContentTree.ROOT_ID, "Audios", "HPlayer MediaServer", new DIDLObject.Class("object.container"), 0); audioContainer.setRestricted(true); audioContainer.setWriteStatus(WriteStatus.NOT_WRITABLE); rootNode.getContainer().addContainer(audioContainer); rootNode.getContainer().setChildCount( rootNode.getContainer().getChildCount() + 1); ContentTree.addNode(ContentTree.AUDIO_ID, new ContentNode( ContentTree.AUDIO_ID, audioContainer)); Cursor cursor = context.getContentResolver() .query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, null, null, null, null); if (cursor == null) { return; } while (cursor.moveToNext()) { String id = ContentTree.AUDIO_PREFIX + cursor.getInt(cursor.getColumnIndex(MediaStore.Audio.Media._ID)); String title = cursor.getString(cursor .getColumnIndexOrThrow(MediaStore.Audio.Media.TITLE)); String creator = cursor.getString(cursor .getColumnIndexOrThrow(MediaStore.Audio.Media.ARTIST)); String filePath = cursor.getString(cursor .getColumnIndexOrThrow(MediaStore.Audio.Media.DATA)); String mimeType = cursor.getString(cursor .getColumnIndexOrThrow(MediaStore.Audio.Media.MIME_TYPE)); long size = cursor.getLong(cursor .getColumnIndexOrThrow(MediaStore.Audio.Media.SIZE)); long duration = cursor.getLong(cursor .getColumnIndexOrThrow(MediaStore.Audio.Media.DURATION)); String album = cursor.getString(cursor .getColumnIndexOrThrow(MediaStore.Audio.Media.ALBUM)); 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); // Music Track must have `artist' with role field, or // DIDLParser().generate(didl) will throw nullpointException MusicTrack musicTrack = new MusicTrack(id, ContentTree.AUDIO_ID, title, creator, album, new PersonWithRole(creator, "Performer"), res); audioContainer.addItem(musicTrack); audioContainer.setChildCount(audioContainer.getChildCount() + 1); ContentTree.addNode(id, new ContentNode(id, musicTrack, filePath)); // Log.d(TAG, "added audio item " + title + "from " + filePath); } cursor.close(); }
Example #17
Source File: MusicAlbum.java From TVRemoteIME with GNU General Public License v2.0 | 4 votes |
public MusicAlbum(String id, String parentID, String title, String creator, Integer childCount, List<MusicTrack> musicTracks) { super(id, parentID, title, creator, childCount); setClazz(CLASS); addMusicTracks(musicTracks); }
Example #18
Source File: DIDLContent.java From DroidDLNA with GNU General Public License v3.0 | 4 votes |
protected List<Item> replaceGenericItems(List<Item> genericItems) { List<Item> specificItems = new ArrayList(); for (Item genericItem : genericItems) { String genericType = genericItem.getClazz().getValue(); if (AudioItem.CLASS.getValue().equals(genericType)) { specificItems.add(new AudioItem(genericItem)); } else if (MusicTrack.CLASS.getValue().equals(genericType)) { specificItems.add(new MusicTrack(genericItem)); } else if (AudioBook.CLASS.getValue().equals(genericType)) { specificItems.add(new AudioBook(genericItem)); } else if (AudioBroadcast.CLASS.getValue().equals(genericType)) { specificItems.add(new AudioBroadcast(genericItem)); } else if (VideoItem.CLASS.getValue().equals(genericType)) { specificItems.add(new VideoItem(genericItem)); } else if (Movie.CLASS.getValue().equals(genericType)) { specificItems.add(new Movie(genericItem)); } else if (VideoBroadcast.CLASS.getValue().equals(genericType)) { specificItems.add(new VideoBroadcast(genericItem)); } else if (MusicVideoClip.CLASS.getValue().equals(genericType)) { specificItems.add(new MusicVideoClip(genericItem)); } else if (ImageItem.CLASS.getValue().equals(genericType)) { specificItems.add(new ImageItem(genericItem)); } else if (Photo.CLASS.getValue().equals(genericType)) { specificItems.add(new Photo(genericItem)); } else if (PlaylistItem.CLASS.getValue().equals(genericType)) { specificItems.add(new PlaylistItem(genericItem)); } else if (TextItem.CLASS.getValue().equals(genericType)) { specificItems.add(new TextItem(genericItem)); } else { specificItems.add(genericItem); } } return specificItems; }
Example #19
Source File: MusicAlbum.java From DroidDLNA with GNU General Public License v3.0 | 4 votes |
public MusicAlbum(String id, Container parent, String title, String creator, Integer childCount) { this(id, parent.getId(), title, creator, childCount, new ArrayList<MusicTrack>()); }
Example #20
Source File: MusicAlbum.java From DroidDLNA with GNU General Public License v3.0 | 4 votes |
public MusicAlbum(String id, Container parent, String title, String creator, Integer childCount, List<MusicTrack> musicTracks) { this(id, parent.getId(), title, creator, childCount, musicTracks); }
Example #21
Source File: MusicAlbum.java From DroidDLNA with GNU General Public License v3.0 | 4 votes |
public MusicAlbum(String id, String parentID, String title, String creator, Integer childCount) { this(id, parentID, title, creator, childCount, new ArrayList<MusicTrack>()); }
Example #22
Source File: MusicAlbum.java From DroidDLNA with GNU General Public License v3.0 | 4 votes |
public MusicAlbum(String id, String parentID, String title, String creator, Integer childCount, List<MusicTrack> musicTracks) { super(id, parentID, title, creator, childCount); setClazz(CLASS); addMusicTracks(musicTracks); }
Example #23
Source File: MusicAlbum.java From TVRemoteIME with GNU General Public License v2.0 | 4 votes |
public MusicAlbum(String id, String parentID, String title, String creator, Integer childCount) { this(id, parentID, title, creator, childCount, new ArrayList<MusicTrack>()); }
Example #24
Source File: MusicAlbum.java From DroidDLNA with GNU General Public License v3.0 | 4 votes |
public void addMusicTracks(List<MusicTrack> musicTracks) { addMusicTracks(musicTracks.toArray(new MusicTrack[musicTracks.size()])); }
Example #25
Source File: MusicAlbum.java From TVRemoteIME with GNU General Public License v2.0 | 4 votes |
public MusicAlbum(String id, Container parent, String title, String creator, Integer childCount, List<MusicTrack> musicTracks) { this(id, parent.getId(), title, creator, childCount, musicTracks); }