Search in sources :

Example 1 with AlbumArtUrl

use of com.sonos.services._1.AlbumArtUrl in project SonosOneDriveServer by bertique.

the class SonosService method buildMC.

private static MediaCollection buildMC(Item m) {
    MediaCollection mc = new MediaCollection();
    if (m.getType().equals(Item.FileType.audio) || (m.getType().equals(Item.FileType.file) && m.getName().endsWith(".flac")) || (m.getType().equals(Item.FileType.file) && m.getMimeType().contains("audio"))) {
        mc.setId(SonosService.AUDIO + ":" + m.getId());
        mc.setItemType(ItemType.TRACK);
        if (m.getTitle() != null && !m.getTitle().isEmpty()) {
            mc.setTitle(m.getTitle());
        } else {
            mc.setTitle(m.getName());
        }
        if (m.getArtist() != null) {
            mc.setArtist(m.getArtist());
        }
        if (m.getThumbnail() != null) {
            AlbumArtUrl art = new AlbumArtUrl();
            art.setValue(m.getThumbnail());
            mc.setAlbumArtURI(art);
        }
        mc.setCanPlay(true);
        mc.setCanEnumerate(false);
    } else if (m.getType().equals(Item.FileType.file)) {
        mc.setId(SonosService.FILE + ":" + m.getId());
        mc.setItemType(ItemType.OTHER);
        mc.setTitle(m.getName());
        mc.setCanPlay(false);
        mc.setCanEnumerate(false);
    } else if (m.getType().equals(Item.FileType.folder)) {
        mc.setId(SonosService.FOLDER + ":" + m.getId());
        mc.setItemType(ItemType.COLLECTION);
        mc.setTitle(m.getName());
        if (m.getChildCount() < 40) {
            mc.setCanPlay(true);
        } else {
            mc.setCanPlay(false);
        }
        mc.setCanEnumerate(true);
    }
    return mc;
}
Also used : MediaCollection(com.sonos.services._1.MediaCollection) AlbumArtUrl(com.sonos.services._1.AlbumArtUrl)

Example 2 with AlbumArtUrl

use of com.sonos.services._1.AlbumArtUrl 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)2 GetMediaMetadata (com.sonos.services._1.GetMediaMetadata)1 MediaCollection (com.sonos.services._1.MediaCollection)1 MediaMetadata (com.sonos.services._1.MediaMetadata)1 TrackMetadata (com.sonos.services._1.TrackMetadata)1