use of com.sonos.services._1.TrackMetadata in project SonosOneDriveServer by bertique.
the class SonosService method buildMMD.
private static MediaMetadata buildMMD(Item m) {
MediaMetadata mmd = new MediaMetadata();
TrackMetadata tmd = new TrackMetadata();
if (m == null)
return null;
mmd.setId(m.getId());
if (m.getType().equals(Item.FileType.file) && m.getName().endsWith(".flac")) {
mmd.setMimeType("audio/flac");
} else if (m.getMimeType().endsWith("wma")) {
mmd.setMimeType("audio/wma");
} else {
mmd.setMimeType(m.getMimeType());
}
mmd.setItemType(ItemType.TRACK);
mmd.setDisplayType("audio");
if (m.getTitle() != null && !m.getTitle().isEmpty()) {
mmd.setTitle(m.getTitle());
} else {
mmd.setTitle(m.getName());
}
if (m.getArtist() != null) {
tmd.setArtist(m.getArtist());
}
if (m.getAlbum() != null) {
tmd.setAlbum(m.getAlbum());
}
if (m.getDuration() > 0) {
tmd.setDuration(m.getDuration());
}
if (m.getThumbnail() != null) {
AlbumArtUrl art = new AlbumArtUrl();
art.setValue(m.getThumbnail());
tmd.setAlbumArtURI(art);
}
tmd.setTrackNumber(m.getTrack());
mmd.setTrackMetadata(tmd);
return mmd;
}
Aggregations