本文整理汇总了Java中org.springframework.web.util.UriComponentsBuilder.toUriString方法的典型用法代码示例。如果您正苦于以下问题:Java UriComponentsBuilder.toUriString方法的具体用法?Java UriComponentsBuilder.toUriString怎么用?Java UriComponentsBuilder.toUriString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.web.util.UriComponentsBuilder
的用法示例。
在下文中一共展示了UriComponentsBuilder.toUriString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createStreamUrl
import org.springframework.web.util.UriComponentsBuilder; //导入方法依赖的package包/类
private String createStreamUrl(HttpServletRequest request, Player player, int id, int offset, int duration, Pair<Integer, Dimension> bitRate) {
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(getContextPath(request) + "ext/stream/stream.ts");
builder.queryParam("id", id);
builder.queryParam("hls", "true");
builder.queryParam("timeOffset", offset);
builder.queryParam("player", player.getId());
builder.queryParam("duration", duration);
if (bitRate != null) {
builder.queryParam("maxBitRate", bitRate.getFirst());
Dimension dimension = bitRate.getSecond();
if (dimension != null) {
builder.queryParam("size", dimension.width);
builder.queryParam("x", dimension.height);
}
}
jwtSecurityService.addJWTToken(builder);
return builder.toUriString();
}
示例2: createResourceForSong
import org.springframework.web.util.UriComponentsBuilder; //导入方法依赖的package包/类
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;
}