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);
}
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 {
HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
HttpServletResponse response = WebContextFactory.get().getHttpServletResponse();

@ -206,17 +206,16 @@
* FIXME: Only works for the Web player for now
*/
function onToggleStartStop() {
var playing = false;
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()) {
playing = jwplayer().getState() == "PLAYING";
if (jwplayer().getState() == "PLAYING") onStop();
else onStart();
} else {
// FIXME for playQueueService
playQueueService.toggleStartStop(playQueueCallback);
}
if (playing) onStop();
else onStart();
}
function onGain(gain) {
@ -239,13 +238,21 @@
function onGainAdd(gain) {
if (CastPlayer.castSession) {
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()) {
var volume = parseInt(jwplayer().getVolume());
jwplayer().setVolume(volume + gain);
var volume = parseInt(jwplayer().getVolume()) + gain;
if (volume > 100) volume = 100;
if (volume < 0) volume = 0;
jwplayer().setVolume(volume);
} else {
var value = parseInt($("#jukeboxVolume").slider("option", "value"));
$("#jukeboxVolume").slider("option", "value", volume);
var volume = parseInt($("#jukeboxVolume").slider("option", "value")) + gain;
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