Search in sources :

Example 1 with PlayStatus

use of org.libresonic.player.domain.PlayStatus in project libresonic by Libresonic.

the class StatusService method getPlayStatuses.

public synchronized List<PlayStatus> getPlayStatuses() {
    Map<String, PlayStatus> result = new LinkedHashMap<String, PlayStatus>();
    for (PlayStatus remotePlay : remotePlays) {
        if (!remotePlay.isExpired()) {
            result.put(remotePlay.getPlayer().getId(), remotePlay);
        }
    }
    List<TransferStatus> statuses = new ArrayList<TransferStatus>();
    statuses.addAll(inactiveStreamStatuses.values());
    statuses.addAll(streamStatuses);
    for (TransferStatus streamStatus : statuses) {
        Player player = streamStatus.getPlayer();
        File file = streamStatus.getFile();
        if (file == null) {
            continue;
        }
        MediaFile mediaFile = mediaFileService.getMediaFile(file);
        if (player == null || mediaFile == null) {
            continue;
        }
        Date time = new Date(System.currentTimeMillis() - streamStatus.getMillisSinceLastUpdate());
        result.put(player.getId(), new PlayStatus(mediaFile, player, time));
    }
    return new ArrayList<PlayStatus>(result.values());
}
Also used : MediaFile(org.libresonic.player.domain.MediaFile) Player(org.libresonic.player.domain.Player) TransferStatus(org.libresonic.player.domain.TransferStatus) MediaFile(org.libresonic.player.domain.MediaFile) File(java.io.File) PlayStatus(org.libresonic.player.domain.PlayStatus)

Example 2 with PlayStatus

use of org.libresonic.player.domain.PlayStatus in project libresonic by Libresonic.

the class StatusService method addRemotePlay.

public synchronized void addRemotePlay(PlayStatus playStatus) {
    Iterator<PlayStatus> iterator = remotePlays.iterator();
    while (iterator.hasNext()) {
        PlayStatus rp = iterator.next();
        if (rp.isExpired()) {
            iterator.remove();
        }
    }
    remotePlays.add(playStatus);
}
Also used : PlayStatus(org.libresonic.player.domain.PlayStatus)

Aggregations

PlayStatus (org.libresonic.player.domain.PlayStatus)2 File (java.io.File)1 MediaFile (org.libresonic.player.domain.MediaFile)1 Player (org.libresonic.player.domain.Player)1 TransferStatus (org.libresonic.player.domain.TransferStatus)1