Java Code Examples for org.seamless.util.MimeType#valueOf()

The following examples show how to use org.seamless.util.MimeType#valueOf() . 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: CustomContentDirectory.java    From airsonic-advanced with GNU General Public License v3.0 6 votes vote down vote up
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(User.USERNAME_ANONYMOUS, 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.getDuration()));
    return res;
}
 
Example 2
Source File: CustomContentDirectory.java    From airsonic with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example 3
Source File: SubsonicContentDirectory.java    From subsonic with GNU General Public License v3.0 5 votes vote down vote up
protected Res createResourceForSong(MediaFile song) {
    Player player = playerService.getGuestPlayer(null);
    String url = getBaseUrl() + "stream?id=" + song.getId() + "&player=" + player.getId();
    if (song.isVideo()) {
        url += "&format=" + TranscodingService.FORMAT_RAW;
    }

    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;
}
 
Example 4
Source File: Icon.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Used internally by Cling when {@link RemoteDevice} is discovered, you shouldn't have to call this.
 */
public Icon(String mimeType, int width, int height, int depth, URI uri) {
    this(mimeType != null && mimeType.length() > 0 ? MimeType.valueOf(mimeType) : null, width, height, depth, uri, null);
}
 
Example 5
Source File: DLNAProtocolInfo.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public DLNAProtocolInfo(DLNAProfiles profile) {
    super(MimeType.valueOf(profile.getContentFormat()));
    this.attributes.put(DLNAAttribute.Type.DLNA_ORG_PN, new DLNAProfileAttribute(profile));
    this.additionalInfo = this.getAttributesString();
}
 
Example 6
Source File: DLNAProtocolInfo.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public DLNAProtocolInfo(DLNAProfiles profile, EnumMap<DLNAAttribute.Type, DLNAAttribute> attributes) {
    super(MimeType.valueOf(profile.getContentFormat()));
    this.attributes.putAll(attributes);
    this.attributes.put(DLNAAttribute.Type.DLNA_ORG_PN, new DLNAProfileAttribute(profile));
    this.additionalInfo = this.getAttributesString();
}
 
Example 7
Source File: ProtocolInfo.java    From TVRemoteIME with GNU General Public License v2.0 4 votes vote down vote up
public MimeType getContentFormatMimeType() throws IllegalArgumentException {
	return MimeType.valueOf(contentFormat);
}
 
Example 8
Source File: Icon.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Used internally by Cling when {@link RemoteDevice} is discovered, you shouldn't have to call this.
 */
public Icon(String mimeType, int width, int height, int depth, URI uri) {
    this(mimeType != null && mimeType.length() > 0 ? MimeType.valueOf(mimeType) : null, width, height, depth, uri, null);
}
 
Example 9
Source File: DLNAProtocolInfo.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public DLNAProtocolInfo(DLNAProfiles profile) {
    super(MimeType.valueOf(profile.getContentFormat()));
    this.attributes.put(DLNAAttribute.Type.DLNA_ORG_PN, new DLNAProfileAttribute(profile));
    this.additionalInfo = this.getAttributesString();
}
 
Example 10
Source File: DLNAProtocolInfo.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public DLNAProtocolInfo(DLNAProfiles profile, EnumMap<DLNAAttribute.Type, DLNAAttribute> attributes) {
    super(MimeType.valueOf(profile.getContentFormat()));
    this.attributes.putAll(attributes);
    this.attributes.put(DLNAAttribute.Type.DLNA_ORG_PN, new DLNAProfileAttribute(profile));
    this.additionalInfo = this.getAttributesString();
}
 
Example 11
Source File: ProtocolInfo.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
public MimeType getContentFormatMimeType() throws IllegalArgumentException {
	return MimeType.valueOf(contentFormat);
}
 
Example 12
Source File: Icon.java    From TVRemoteIME with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Use this constructor if your local icon data is in a <code>byte[]</code>.
 *
 * @param uniqueName Must be a valid URI path segment and unique within the scope of a device.
 */
public Icon(String mimeType, int width, int height, int depth, String uniqueName, byte[] data) {
    this(mimeType != null && mimeType.length() > 0 ? MimeType.valueOf(mimeType) : null, width, height, depth, URI.create(uniqueName), data);
}
 
Example 13
Source File: Icon.java    From DroidDLNA with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Use this constructor if your local icon data is in a <code>byte[]</code>.
 *
 * @param uniqueName Must be a valid URI path segment and unique within the scope of a device.
 */
public Icon(String mimeType, int width, int height, int depth, String uniqueName, byte[] data) {
    this(mimeType != null && mimeType.length() > 0 ? MimeType.valueOf(mimeType) : null, width, height, depth, URI.create(uniqueName), data);
}