Merge remote-tracking branch 'airsonic/pr/859'

master
Andrew DeMaria 6 years ago
commit 5e14996dc3
No known key found for this signature in database
GPG Key ID: 0A3F5E91F8364EDF
  1. 34
      airsonic-main/src/main/webapp/WEB-INF/jsp/playQueue.jsp

@ -167,15 +167,17 @@
} }
/** /**
* Start playing from the current playlist * Start/resume playing from the current playlist
*/ */
function onStart() { function onStart() {
if (CastPlayer.castSession) { if (CastPlayer.castSession) {
CastPlayer.playCast(); CastPlayer.playCast();
} else if ($('#audioPlayer').get(0)) { } else if ($('#audioPlayer').get(0)) {
var audioPlayer = $('#audioPlayer'); if ($('#audioPlayer').get(0).src) {
if(audioPlayer.paused) { $('#audioPlayer').get(0).play(); // Resume playing if the player was paused
skip(0, audioPlayer.currentTime); }
else {
skip(0); // Start the first track if the player was not yet loaded
} }
} else { } else {
playQueueService.start(playQueueCallback); playQueueService.start(playQueueCallback);
@ -205,8 +207,9 @@
var 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(); if (playing) onStop();
else onStart(); else onStart();
} else if ($('#audioPlayer')) { } else if ($('#audioPlayer').get(0)) {
if (!$('#audioPlayer').get(0).paused) onStop(); var playing = $("#audioPlayer").get(0).paused != null && !$("#audioPlayer").get(0).paused;
if (playing) onStop();
else onStart(); else onStart();
} else { } else {
playQueueService.toggleStartStop(playQueueCallback); playQueueService.toggleStartStop(playQueueCallback);
@ -237,11 +240,11 @@
if (volume < 0) volume = 0; if (volume < 0) volume = 0;
CastPlayer.setCastVolume(volume / 100, false); CastPlayer.setCastVolume(volume / 100, false);
$("#castVolume").slider("option", "value", volume); // Need to update UI $("#castVolume").slider("option", "value", volume); // Need to update UI
} else if ($('#audioPlayer')) { } else if ($('#audioPlayer').get(0)) {
var volume = parseInt($('#audioPlayer').get(0).volume) + gain; var volume = parseFloat($('#audioPlayer').get(0).volume)*100 + gain;
if (volume > 100) volume = 100; if (volume > 100) volume = 100;
if (volume < 0) volume = 0; if (volume < 0) volume = 0;
$('#audioPlayer').get(0).volume = volume; $('#audioPlayer').get(0).volume = volume / 100;
} else { } else {
var volume = parseInt($("#jukeboxVolume").slider("option", "value")) + gain; var volume = parseInt($("#jukeboxVolume").slider("option", "value")) + gain;
if (volume > 100) volume = 100; if (volume > 100) volume = 100;
@ -360,7 +363,7 @@
playQueueService.sortByAlbum(playQueueCallback); playQueueService.sortByAlbum(playQueueCallback);
} }
function onSavePlayQueue() { function onSavePlayQueue() {
var positionMillis = $('#audioPlayer') ? Math.round(1000.0 * $('#audioPlayer').get(0).currentTime) : 0; var positionMillis = $('#audioPlayer').get(0) ? Math.round(1000.0 * $('#audioPlayer').get(0).currentTime) : 0;
playQueueService.savePlayQueue(getCurrentSongIndex(), positionMillis); playQueueService.savePlayQueue(getCurrentSongIndex(), positionMillis);
$().toastmessage("showSuccessToast", "<fmt:message key="playlist.toast.saveplayqueue"/>"); $().toastmessage("showSuccessToast", "<fmt:message key="playlist.toast.saveplayqueue"/>");
} }
@ -542,10 +545,13 @@
if (CastPlayer.castSession) { if (CastPlayer.castSession) {
CastPlayer.loadCastMedia(song, position); CastPlayer.loadCastMedia(song, position);
} else { } else {
$('#audioPlayer').get(0).src = song.streamUrl; if ($('#audioPlayer').get(0).src != song.streamUrl) {
$('#audioPlayer').get(0).load(); $('#audioPlayer').get(0).src = song.streamUrl;
$('#audioPlayer').get(0).load();
console.log(song.streamUrl);
}
$('#audioPlayer').get(0).currentTime = position ? position : 0;
$('#audioPlayer').get(0).play(); $('#audioPlayer').get(0).play();
console.log(song.streamUrl);
} }
updateWindowTitle(song); updateWindowTitle(song);
@ -689,7 +695,7 @@
<c:if test="${model.player.web}"> <c:if test="${model.player.web}">
<td> <td>
<div id="player" style="width:340px; height:40px;padding-right:10px"> <div id="player" style="width:340px; height:40px;padding-right:10px">
<audio id="audioPlayer" class="mejs__player" data-mejsoptions='{"alwaysShowControls": "true"}' width="340px" height"40px"/> <audio id="audioPlayer" class="mejs__player" data-mejsoptions='{"alwaysShowControls": true, "enableKeyboard": false}' width="340px" height"40px" tabindex="-1" />
</div> </div>
<div id="castPlayer" style="display: none"> <div id="castPlayer" style="display: none">
<div style="float:left"> <div style="float:left">

Loading…
Cancel
Save