Search in sources :

Example 1 with MimeType

use of org.seamless.util.MimeType in project libresonic by Libresonic.

the class LibresonicContentDirectory method createResourceForSong.

protected Res createResourceForSong(MediaFile song) {
    Player player = playerService.getGuestPlayer(null);
    UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(getBaseUrl() + "/ext/stream").queryParam("id", song.getId()).queryParam("player", player.getId());
    if (song.isVideo()) {
        builder.queryParam("format", TranscodingService.FORMAT_RAW);
    }
    jwtSecurityService.addJWTToken(builder);
    String url = builder.toUriString();
    String suffix = song.isVideo() ? FilenameUtils.getExtension(song.getPath()) : transcodingService.getSuffix(player, song, null);
    String mimeTypeString = StringUtil.getMimeType(suffix);
    MimeType mimeType = mimeTypeString == null ? null : MimeType.valueOf(mimeTypeString);
    Res res = new Res(mimeType, null, url);
    res.setDuration(formatDuration(song.getDurationSeconds()));
    return res;
}
Also used : Res(org.fourthline.cling.support.model.Res) Player(org.libresonic.player.domain.Player) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) MimeType(org.seamless.util.MimeType)

Aggregations

Res (org.fourthline.cling.support.model.Res)1 Player (org.libresonic.player.domain.Player)1 MimeType (org.seamless.util.MimeType)1 UriComponentsBuilder (org.springframework.web.util.UriComponentsBuilder)1