Make shortcuts work in Jukebox mode

master
François-Xavier Thomas 9 years ago
parent 4f2887e60a
commit 349143cff1
No known key found for this signature in database
GPG Key ID: 64337406D2DD45CE
  1. 16
      libresonic-main/src/main/java/org/libresonic/player/ajax/PlayQueueService.java
  2. 31
      libresonic-main/src/main/webapp/WEB-INF/jsp/playQueue.jsp

@ -119,6 +119,22 @@ public class PlayQueueService {
return convert(request, player, true); return convert(request, player, true);
} }
public PlayQueueInfo toggleStartStop() throws Exception {
HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
HttpServletResponse response = WebContextFactory.get().getHttpServletResponse();
return doToggleStartStop(request, response);
}
public PlayQueueInfo doToggleStartStop(HttpServletRequest request, HttpServletResponse response) throws Exception {
Player player = getCurrentPlayer(request, response);
if (player.getPlayQueue().getStatus() == PlayQueue.Status.STOPPED) {
player.getPlayQueue().setStatus(PlayQueue.Status.PLAYING);
} else if (player.getPlayQueue().getStatus() == PlayQueue.Status.PLAYING) {
player.getPlayQueue().setStatus(PlayQueue.Status.STOPPED);
}
return convert(request, player, true);
}
public PlayQueueInfo skip(int index) throws Exception { public PlayQueueInfo skip(int index) throws Exception {
HttpServletRequest request = WebContextFactory.get().getHttpServletRequest(); HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
HttpServletResponse response = WebContextFactory.get().getHttpServletResponse(); HttpServletResponse response = WebContextFactory.get().getHttpServletResponse();

@ -206,17 +206,16 @@
* FIXME: Only works for the Web player for now * FIXME: Only works for the Web player for now
*/ */
function onToggleStartStop() { function onToggleStartStop() {
var playing = false;
if (CastPlayer.castSession) { if (CastPlayer.castSession) {
playing = CastPlayer.mediaSession && CastPlayer.mediaSession.playerState == chrome.cast.media.PlayerState.PLAYING; var playing = CastPlayer.mediaSession && CastPlayer.mediaSession.playerState == chrome.cast.media.PlayerState.PLAYING;
if (playing) onStop();
else onStart();
} else if (jwplayer()) { } else if (jwplayer()) {
playing = jwplayer().getState() == "PLAYING"; if (jwplayer().getState() == "PLAYING") onStop();
else onStart();
} else { } else {
// FIXME for playQueueService playQueueService.toggleStartStop(playQueueCallback);
} }
if (playing) onStop();
else onStart();
} }
function onGain(gain) { function onGain(gain) {
@ -239,13 +238,21 @@
function onGainAdd(gain) { function onGainAdd(gain) {
if (CastPlayer.castSession) { if (CastPlayer.castSession) {
var volume = parseInt($("#castVolume").slider("option", "value")) + gain; var volume = parseInt($("#castVolume").slider("option", "value")) + gain;
$("#castVolume").slider("option", "value", volume); if (volume > 100) volume = 100;
if (volume < 0) volume = 0;
CastPlayer.setCastVolume(volume / 100, false);
$("#castVolume").slider("option", "value", volume); // Need to update UI
} else if (jwplayer()) { } else if (jwplayer()) {
var volume = parseInt(jwplayer().getVolume()); var volume = parseInt(jwplayer().getVolume()) + gain;
jwplayer().setVolume(volume + gain); if (volume > 100) volume = 100;
if (volume < 0) volume = 0;
jwplayer().setVolume(volume);
} else { } else {
var value = parseInt($("#jukeboxVolume").slider("option", "value")); var volume = parseInt($("#jukeboxVolume").slider("option", "value")) + gain;
$("#jukeboxVolume").slider("option", "value", volume); if (volume > 100) volume = 100;
if (volume < 0) volume = 0;
onGain(volume / 100);
$("#jukeboxVolume").slider("option", "value", volume); // Need to update UI
} }
} }

Loading…
Cancel
Save