當前位置: 首頁>>代碼示例>>Java>>正文


Java StringUtil.parseRange方法代碼示例

本文整理匯總了Java中net.sourceforge.subsonic.util.StringUtil.parseRange方法的典型用法代碼示例。如果您正苦於以下問題:Java StringUtil.parseRange方法的具體用法?Java StringUtil.parseRange怎麽用?Java StringUtil.parseRange使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.sourceforge.subsonic.util.StringUtil的用法示例。


在下文中一共展示了StringUtil.parseRange方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getRange

import net.sourceforge.subsonic.util.StringUtil; //導入方法依賴的package包/類
private LongRange getRange(HttpServletRequest request, MediaFile file) {

        // First, look for "Range" HTTP header.
        LongRange range = StringUtil.parseRange(request.getHeader("Range"));
        if (range != null) {
            return range;
        }

        // Second, look for "offsetSeconds" request parameter.
        String offsetSeconds = request.getParameter("offsetSeconds");
        range = parseAndConvertOffsetSeconds(offsetSeconds, file);
        if (range != null) {
            return range;
        }

        return null;
    }
 
開發者ID:FutureSonic,項目名稱:FutureSonic-Server,代碼行數:18,代碼來源:StreamController.java

示例2: handleRequest

import net.sourceforge.subsonic.util.StringUtil; //導入方法依賴的package包/類
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {

        TransferStatus status = null;
        try {

            status = statusService.createDownloadStatus(playerService.getPlayer(request, response, false, false));

            MediaFile mediaFile = getMediaFile(request);
            Integer playlistId = ServletRequestUtils.getIntParameter(request, "playlist");
            String playerId = request.getParameter("player");
            int[] indexes = request.getParameter("i") == null ? null : ServletRequestUtils.getIntParameters(request, "i");

            if (mediaFile != null) {
                response.setIntHeader("ETag", mediaFile.getId());
                response.setHeader("Accept-Ranges", "bytes");
            }

            LongRange range = StringUtil.parseRange(request.getHeader("Range"));
            if (range != null) {
                response.setStatus(HttpServletResponse.SC_PARTIAL_CONTENT);
                LOG.info("Got range: " + range);
            }

            if (mediaFile != null) {
                if (mediaFile.isFile()) {
                    downloadFile(response, status, mediaFile.getFile(), range);
                } else {
                    List<MediaFile> children = mediaFileService.getChildrenOf(mediaFile, true, true, true);
                    String zipFileName = FilenameUtils.getBaseName(mediaFile.getPath()) + ".zip";
                    downloadFiles(response, status, children, indexes, range, zipFileName);
                }

            } else if (playlistId != null) {
                List<MediaFile> songs = playlistService.getFilesInPlaylist(playlistId);
                Playlist playlist = playlistService.getPlaylist(playlistId);
                downloadFiles(response, status, songs, null, range, playlist.getName() + ".zip");

            } else if (playerId != null) {
                Player player = playerService.getPlayerById(playerId);
                PlayQueue playQueue = player.getPlayQueue();
                playQueue.setName("Playlist");
                downloadFiles(response, status, playQueue.getFiles(), indexes, range, "download.zip");
            }

        } finally {
            if (status != null) {
                statusService.removeDownloadStatus(status);
                User user = securityService.getCurrentUser(request);
                securityService.updateUserByteCounts(user, 0L, status.getBytesTransfered(), 0L);
            }
        }

        return null;
    }
 
開發者ID:FutureSonic,項目名稱:FutureSonic-Server,代碼行數:55,代碼來源:DownloadController.java


注:本文中的net.sourceforge.subsonic.util.StringUtil.parseRange方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。