当前位置: 首页>>代码示例>>Java>>正文


Java PlayQueue类代码示例

本文整理汇总了Java中net.sourceforge.subsonic.domain.PlayQueue的典型用法代码示例。如果您正苦于以下问题:Java PlayQueue类的具体用法?Java PlayQueue怎么用?Java PlayQueue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PlayQueue类属于net.sourceforge.subsonic.domain包,在下文中一共展示了PlayQueue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateJukebox

import net.sourceforge.subsonic.domain.PlayQueue; //导入依赖的package包/类
/**
 * Updates the jukebox by starting or pausing playback on the local audio device.
 *
 * @param player The player in question.
 * @param offset Start playing after this many seconds into the track.
 */
public synchronized void updateJukebox(Player player, int offset) throws Exception {
    User user = securityService.getUserByName(player.getUsername());
    if (!user.isJukeboxRole()) {
        LOG.warn(user.getUsername() + " is not authorized for jukebox playback.");
        return;
    }

    if (player.getPlayQueue().getStatus() == PlayQueue.Status.PLAYING) {
        this.player = player;
        MediaFile result;
        synchronized (player.getPlayQueue()) {
            result = player.getPlayQueue().getCurrentFile();
        }
        play(result, offset);
    } else {
        if (audioPlayer != null) {
            audioPlayer.pause();
        }
    }
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:27,代码来源:JukeboxService.java

示例2: read

import net.sourceforge.subsonic.domain.PlayQueue; //导入依赖的package包/类
@Override
public int read(byte[] b, int off, int len) throws IOException {
    prepare();
    if (currentInputStream == null || player.getPlayQueue().getStatus() == PlayQueue.Status.STOPPED) {
        return -1;
    }

    int n = currentInputStream.read(b, off, len);

    // If end of song reached, skip to next song and call read() again.
    if (n == -1) {
        player.getPlayQueue().next();
        close();
        return read(b, off, len);
    } else {
        status.addBytesTransfered(n);
    }
    return n;
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:20,代码来源:PlayQueueInputStream.java

示例3: savePlayQueue

import net.sourceforge.subsonic.domain.PlayQueue; //导入依赖的package包/类
public void savePlayQueue(int currentSongIndex, long positionMillis) {
    HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
    HttpServletResponse response = WebContextFactory.get().getHttpServletResponse();

    Player player = getCurrentPlayer(request, response);
    String username = securityService.getCurrentUsername(request);
    PlayQueue playQueue = player.getPlayQueue();
    List<Integer> ids = MediaFile.toIdList(playQueue.getFiles());

    Integer currentId = currentSongIndex == -1 ? null : playQueue.getFile(currentSongIndex).getId();
    SavedPlayQueue savedPlayQueue = new SavedPlayQueue(null, username, ids, currentId, positionMillis, new Date(), "Subsonic");
    playQueueDao.savePlayQueue(savedPlayQueue);
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:14,代码来源:PlayQueueService.java

示例4: loadPlayQueue

import net.sourceforge.subsonic.domain.PlayQueue; //导入依赖的package包/类
public PlayQueueInfo loadPlayQueue() throws Exception {
    HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
    HttpServletResponse response = WebContextFactory.get().getHttpServletResponse();
    Player player = getCurrentPlayer(request, response);
    String username = securityService.getCurrentUsername(request);
    SavedPlayQueue savedPlayQueue = playQueueDao.getPlayQueue(username);

    if (savedPlayQueue == null) {
        return convert(request, player, false);
    }

    PlayQueue playQueue = player.getPlayQueue();
    playQueue.clear();
    for (Integer mediaFileId : savedPlayQueue.getMediaFileIds()) {
        MediaFile mediaFile = mediaFileService.getMediaFile(mediaFileId);
        if (mediaFile != null) {
            playQueue.addFiles(true, mediaFile);
        }
    }
    PlayQueueInfo result = convert(request, player, false);

    Integer currentId = savedPlayQueue.getCurrentMediaFileId();
    int currentIndex = -1;
    long positionMillis = savedPlayQueue.getPositionMillis() == null ? 0L : savedPlayQueue.getPositionMillis();
    if (currentId != null) {
        MediaFile current = mediaFileService.getMediaFile(currentId);
        currentIndex = playQueue.getFiles().indexOf(current);
        if (currentIndex != -1) {
            result.setStartPlayerAt(currentIndex);
            result.setStartPlayerAtPosition(positionMillis);
        }
    }

    boolean serverSidePlaylist = !player.isExternalWithPlaylist();
    if (serverSidePlaylist && currentIndex != -1) {
        doSkip(request, response, currentIndex, (int) (positionMillis / 1000L));
    }

    return result;
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:41,代码来源:PlayQueueService.java

示例5: doSet

import net.sourceforge.subsonic.domain.PlayQueue; //导入依赖的package包/类
public PlayQueueInfo doSet(HttpServletRequest request, HttpServletResponse response, int[] ids) throws Exception {
    Player player = getCurrentPlayer(request, response);
    PlayQueue playQueue = player.getPlayQueue();
    MediaFile currentFile = playQueue.getCurrentFile();
    PlayQueue.Status status = playQueue.getStatus();

    playQueue.clear();
    PlayQueueInfo result = doAdd(request, response, ids, null);

    int index = currentFile == null ? -1 : playQueue.getFiles().indexOf(currentFile);
    playQueue.setIndex(index);
    playQueue.setStatus(status);
    return result;
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:15,代码来源:PlayQueueService.java

示例6: sortByTrack

import net.sourceforge.subsonic.domain.PlayQueue; //导入依赖的package包/类
public PlayQueueInfo sortByTrack() throws Exception {
    HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
    HttpServletResponse response = WebContextFactory.get().getHttpServletResponse();
    Player player = getCurrentPlayer(request, response);
    player.getPlayQueue().sort(PlayQueue.SortOrder.TRACK);
    return convert(request, player, false);
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:8,代码来源:PlayQueueService.java

示例7: sortByArtist

import net.sourceforge.subsonic.domain.PlayQueue; //导入依赖的package包/类
public PlayQueueInfo sortByArtist() throws Exception {
    HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
    HttpServletResponse response = WebContextFactory.get().getHttpServletResponse();
    Player player = getCurrentPlayer(request, response);
    player.getPlayQueue().sort(PlayQueue.SortOrder.ARTIST);
    return convert(request, player, false);
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:8,代码来源:PlayQueueService.java

示例8: sortByAlbum

import net.sourceforge.subsonic.domain.PlayQueue; //导入依赖的package包/类
public PlayQueueInfo sortByAlbum() throws Exception {
    HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
    HttpServletResponse response = WebContextFactory.get().getHttpServletResponse();
    Player player = getCurrentPlayer(request, response);
    player.getPlayQueue().sort(PlayQueue.SortOrder.ALBUM);
    return convert(request, player, false);
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:8,代码来源:PlayQueueService.java

示例9: handleRequestInternal

import net.sourceforge.subsonic.domain.PlayQueue; //导入依赖的package包/类
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {

        int size = ServletRequestUtils.getRequiredIntParameter(request, "size");
        String genre = request.getParameter("genre");
        if (StringUtils.equalsIgnoreCase("any", genre)) {
            genre = null;
        }

        Integer fromYear = null;
        Integer toYear = null;

        String year = request.getParameter("year");
        if (!StringUtils.equalsIgnoreCase("any", year)) {
            String[] tmp = StringUtils.split(year);
            fromYear = Integer.parseInt(tmp[0]);
            toYear = Integer.parseInt(tmp[1]);
        }

        List<MusicFolder> musicFolders = getMusicFolders(request);
        Player player = playerService.getPlayer(request, response);
        PlayQueue playQueue = player.getPlayQueue();

        RandomSearchCriteria criteria = new RandomSearchCriteria(size, genre, fromYear, toYear, musicFolders);
        playQueue.addFiles(false, searchService.getRandomSongs(criteria));

        if (request.getParameter("autoRandom") != null) {
            playQueue.setRandomSearchCriteria(criteria);
        }

        Map<String, Object> map = new HashMap<String, Object>();
        map.put("reloadFrames", reloadFrames);

        ModelAndView result = super.handleRequestInternal(request, response);
        result.addObject("model", map);
        return result;
    }
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:37,代码来源:RandomPlayQueueController.java

示例10: getPlayQueue

import net.sourceforge.subsonic.domain.PlayQueue; //导入依赖的package包/类
@SuppressWarnings("UnusedDeclaration")
public void getPlayQueue(HttpServletRequest request, HttpServletResponse response) throws Exception {
    request = wrapRequest(request);
    String username = securityService.getCurrentUsername(request);
    Player player = playerService.getPlayer(request, response);

    SavedPlayQueue playQueue = playQueueDao.getPlayQueue(username);
    if (playQueue == null) {
        writeEmptyResponse(request, response);
        return;
    }

    org.subsonic.restapi.PlayQueue restPlayQueue = new org.subsonic.restapi.PlayQueue();
    restPlayQueue.setUsername(playQueue.getUsername());
    restPlayQueue.setCurrent(playQueue.getCurrentMediaFileId());
    restPlayQueue.setPosition(playQueue.getPositionMillis());
    restPlayQueue.setChanged(jaxbWriter.convertDate(playQueue.getChanged()));
    restPlayQueue.setChangedBy(playQueue.getChangedBy());

    for (Integer mediaFileId : playQueue.getMediaFileIds()) {
        MediaFile mediaFile = mediaFileService.getMediaFile(mediaFileId);
        if (mediaFile != null) {
            restPlayQueue.getEntry().add(createJaxbChild(player, mediaFile, username));
        }
    }

    Response res = createResponse();
    res.setPlayQueue(restPlayQueue);
    jaxbWriter.writeResponse(request, response, res);
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:31,代码来源:RESTController.java

示例11: getMediaFiles

import net.sourceforge.subsonic.domain.PlayQueue; //导入依赖的package包/类
private List<MediaFile> getMediaFiles(HttpServletRequest request) throws Exception {
    Integer id = ServletRequestUtils.getIntParameter(request, "id");
    String playerId = request.getParameter("player");
    Integer playlistId = ServletRequestUtils.getIntParameter(request, "playlist");

    List<MediaFile> result = new ArrayList<MediaFile>();

    if (id != null) {
        MediaFile album = mediaFileService.getMediaFile(id);
        int[] indexes = ServletRequestUtils.getIntParameters(request, "i");
        if (indexes.length == 0) {
            return Arrays.asList(album);
        }
        List<MediaFile> children = mediaFileService.getChildrenOf(album, true, false, true);
        for (int index : indexes) {
            result.add(children.get(index));
        }
    }

    else if (playerId != null) {
        Player player = playerService.getPlayerById(playerId);
        PlayQueue playQueue = player.getPlayQueue();
        result = playQueue.getFiles();
    }

    else if (playlistId != null) {
        result = playlistService.getFilesInPlaylist(playlistId);
    }

    return result;
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:32,代码来源:ShareManagementController.java

示例12: prepare

import net.sourceforge.subsonic.domain.PlayQueue; //导入依赖的package包/类
private void prepare() throws IOException {
    PlayQueue playQueue = player.getPlayQueue();

    // If playlist is in auto-random mode, populate it with new random songs.
    if (playQueue.getIndex() == -1 && playQueue.getRandomSearchCriteria() != null) {
        populateRandomPlaylist(playQueue);
    }

    MediaFile result;
    synchronized (playQueue) {
        result = playQueue.getCurrentFile();
    }
    MediaFile file = result;
    if (file == null) {
        close();
    } else if (!file.equals(currentFile)) {
        close();
        LOG.info(player.getUsername() + " listening to \"" + FileUtil.getShortPath(file.getFile()) + "\"");
        mediaFileService.incrementPlayCount(file);

        // Don't scrobble REST players (except Sonos)
        if (player.getClientId() == null || player.getClientId().equals(SonosHelper.SUBSONIC_CLIENT_ID)) {
            audioScrobblerService.register(file, player.getUsername(), false, null);
        }

        TranscodingService.Parameters parameters = transcodingService.getParameters(file, player, maxBitRate, preferredTargetFormat, videoTranscodingSettings);
        currentInputStream = transcodingService.getTranscodedInputStream(parameters);
        currentFile = file;
        status.setFile(currentFile.getFile());
    }
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:32,代码来源:PlayQueueInputStream.java

示例13: testPlaylist

import net.sourceforge.subsonic.domain.PlayQueue; //导入依赖的package包/类
public void testPlaylist() {
    Player player = new Player();
    playerDao.createPlayer(player);
    PlayQueue playQueue = player.getPlayQueue();
    assertNotNull("Missing playlist.", playQueue);

    playerDao.deletePlayer(player.getId());
    playerDao.createPlayer(player);
    assertNotSame("Wrong playlist.", playQueue, player.getPlayQueue());
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:11,代码来源:PlayerDaoTestCase.java

示例14: convert

import net.sourceforge.subsonic.domain.PlayQueue; //导入依赖的package包/类
private PlayQueueInfo convert(HttpServletRequest request, Player player, boolean sendM3U, int offset) throws Exception {
    String url = request.getRequestURL().toString();

    if (sendM3U && player.isJukebox()) {
        jukeboxService.updateJukebox(player, offset);
    }
    boolean isCurrentPlayer = player.getIpAddress() != null && player.getIpAddress().equals(request.getRemoteAddr());

    boolean m3uSupported = player.isExternal() || player.isExternalWithPlaylist();
    sendM3U = player.isAutoControlEnabled() && m3uSupported && isCurrentPlayer && sendM3U;
    Locale locale = RequestContextUtils.getLocale(request);

    List<PlayQueueInfo.Entry> entries = new ArrayList<PlayQueueInfo.Entry>();
    PlayQueue playQueue = player.getPlayQueue();
    for (MediaFile file : playQueue.getFiles()) {
        String albumUrl = url.replaceFirst("/dwr/.*", "/main.view?id=" + file.getId());
        String streamUrl = url.replaceFirst("/dwr/.*", "/stream?player=" + player.getId() + "&id=" + file.getId());

        // Rewrite URLs in case we're behind a proxy.
        if (settingsService.isRewriteUrlEnabled()) {
            String referer = request.getHeader("referer");
            albumUrl = StringUtil.rewriteUrl(albumUrl, referer);
            streamUrl = StringUtil.rewriteUrl(streamUrl, referer);
        }

        String format = formatFormat(player, file);
        String username = securityService.getCurrentUsername(request);
        boolean starred = mediaFileService.getMediaFileStarredDate(file.getId(), username) != null;
        entries.add(new PlayQueueInfo.Entry(file.getId(), file.getTrackNumber(), file.getTitle(), file.getArtist(),
                file.getAlbumName(), file.getGenre(), file.getMood(), file.getYear(), formatBitRate(file),
                file.getDurationSeconds(), file.getDurationString(), format, formatContentType(format),
                formatFileSize(file.getFileSize(), locale), starred, albumUrl, streamUrl));
    }
    boolean isStopEnabled = playQueue.getStatus() == PlayQueue.Status.PLAYING && !player.isExternalWithPlaylist();
    float gain = jukeboxService.getGain();
    return new PlayQueueInfo(entries, playQueue.getIndex(), isStopEnabled, playQueue.isRepeatEnabled(), playQueue.isPandoraEnabled(), sendM3U, gain);
}
 
开发者ID:FutureSonic,项目名称:FutureSonic-Server,代码行数:38,代码来源:PlayQueueService.java

示例15: handleRequestInternal

import net.sourceforge.subsonic.domain.PlayQueue; //导入依赖的package包/类
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {

        int size = ServletRequestUtils.getRequiredIntParameter(request, "size");
        String genre = request.getParameter("genre");
        if (StringUtils.equalsIgnoreCase("any", genre)) {
            genre = null;
        }

        Integer fromYear = null;
        Integer toYear = null;

        String year = request.getParameter("year");
        if (!StringUtils.equalsIgnoreCase("any", year)) {
            String[] tmp = StringUtils.split(year);
            fromYear = Integer.parseInt(tmp[0]);
            toYear = Integer.parseInt(tmp[1]);
        }

        Integer musicFolderId = ServletRequestUtils.getRequiredIntParameter(request, "musicFolderId");
        if (musicFolderId == -1) {
            musicFolderId = null;
        }

        Player player = playerService.getPlayer(request, response);
        PlayQueue playQueue = player.getPlayQueue();

        RandomSearchCriteria criteria = new RandomSearchCriteria(size, genre, fromYear, toYear, musicFolderId);
        playQueue.addFiles(false, searchService.getRandomSongs(criteria));

        if (request.getParameter("autoRandom") != null) {
            playQueue.setRandomSearchCriteria(criteria);
        }

        Map<String, Object> map = new HashMap<String, Object>();
        map.put("reloadFrames", reloadFrames);

        ModelAndView result = super.handleRequestInternal(request, response);
        result.addObject("model", map);
        return result;
    }
 
开发者ID:FutureSonic,项目名称:FutureSonic-Server,代码行数:41,代码来源:RandomPlayQueueController.java


注:本文中的net.sourceforge.subsonic.domain.PlayQueue类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。