Search in sources :

Example 1 with TrackMetadata

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;
}
Also used : TrackMetadata(com.sonos.services._1.TrackMetadata) MediaMetadata(com.sonos.services._1.MediaMetadata) GetMediaMetadata(com.sonos.services._1.GetMediaMetadata) AlbumArtUrl(com.sonos.services._1.AlbumArtUrl)

Aggregations

AlbumArtUrl (com.sonos.services._1.AlbumArtUrl)1 GetMediaMetadata (com.sonos.services._1.GetMediaMetadata)1 MediaMetadata (com.sonos.services._1.MediaMetadata)1 TrackMetadata (com.sonos.services._1.TrackMetadata)1