Skip to content

Commit 2805f12

Browse files
committed
Add "Crop queue" feature
1 parent e3aa0cb commit 2805f12

File tree

5 files changed

+18
-3
lines changed

5 files changed

+18
-3
lines changed

www/command/queue.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,15 @@
5656
echo json_encode(parseDelimFile(readMpdResp($sock), ': ')['file']);
5757
break;
5858
case 'clear_playqueue':
59-
workerLog('clear_playqueue');
59+
//workerLog('clear_playqueue');
6060
sendMpdCmd($sock, 'clear');
6161
$resp = readMpdResp($sock);
6262
updLibRecentPlaylistVar('None');
6363
break;
64+
case 'crop_playqueue':
65+
//workerLog('crop_playqueue');
66+
sysCmd('mpc crop');
67+
break;
6468
case 'add_item':
6569
case 'add_item_next':
6670
$status = getMpdStatus($sock);

www/js/notify.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ function notify(title, message, arg3, arg4 = '') {
2222
queue_item_removed: 'Selected items have been removed. ',
2323
queue_item_moved: 'Selected items have been moved. ',
2424
queue_cleared: 'Queue has been cleared. ',
25+
queue_cropped: 'Queue has been cropped. ',
2526
playqueue_info: '<br>',
2627
// Library
2728
update_library: 'Library is being updated... ',

www/js/scripts-library.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,6 +1749,12 @@ $('#context-menu-playback a').click(function(e) {
17491749
$('#playlist-save-name').val('');
17501750
notify(NOTIFY_TITLE_INFO, 'queue_cleared', NOTIFY_DURATION_SHORT);
17511751
});
1752+
break;
1753+
case 'crop':
1754+
$.post('command/queue.php?cmd=crop_playqueue', function() {
1755+
$('#playlist-save-name').val('');
1756+
notify(NOTIFY_TITLE_INFO, 'queue_cropped', NOTIFY_DURATION_SHORT);
1757+
});
17521758
break;
17531759
case 'stream_recorder':
17541760
$('#menu-check-recorder').toggle();

www/quickhelp.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ <h5>Queue</h5>
104104
<p>The "Add next" command adds the item immediately after the currently playing or last played item. The "Play next" command first checks to see if the item is already in the Queue and then plays the existing item otherwise it does the same as "Add next" then begins play.</p>
105105
</li>
106106
<li><span> Clear queue</span>
107-
<p>This command is available in the ellipsis context menu in Playback view and on the Playbar.</p>
107+
<p>Remove all songs in the Queue. This command is available in the ellipsis context menu in Playback view and on the Playbar.</p>
108+
</li>
109+
<li><span> Crop queue</span>
110+
<p>Remove all songs except for the currently playing song. This command is available in the ellipsis context menu in Playback view and on the Playbar.</p>
108111
</li>
109112
<li>
110113
<p>For the track list in Library Tag and Album views the Play and Clear/Play actions can be configured via a Preferences option to either add the selected track to the Queue or the selected track and all following tracks.</p>

www/templates/indextpl.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2904,7 +2904,8 @@ <h3 id="playhistory-modal-label">Playback history</h3>
29042904
<li><a href="#notarget" data-cmd="consume"><i class="fa-regular fa-sharp fa-arrow-down sx"></i> Consume<span id="menu-check-consume"><i class="fa-solid fa-sharp fa-check"></i></span></a></li>
29052905
<li><a href="#notarget" data-cmd="repeat"><i class="fa-regular fa-sharp fa-repeat sx"></i> Repeat<span id="menu-check-repeat"><i class="fa-solid fa-sharp fa-check"></i></span></a></li>
29062906
<li><a href="#notarget" data-cmd="single"><i class="fa-regular fa-sharp fa-redo sx"></i> Single<span id="menu-check-single"><i class="fa-solid fa-sharp fa-check"></i></span></a></li>
2907-
<li class="menu-separator"><a href="#notarget" data-cmd="clear"><i class="fa-regular fa-sharp fa-trash sx"></i> Clear queue</a></li>
2907+
<li><a href="#notarget" data-cmd="clear"><i class="fa-regular fa-sharp fa-trash sx"></i> Clear queue</a></li>
2908+
<li class="menu-separator"><a href="#notarget" data-cmd="crop"><i class="fa-regular fa-sharp fa-crop-simple sx"></i> Crop queue</a></li>
29082909
<li id="context-menu-stream-recorder" class="hide"><a href="#notarget" data-cmd="stream_recorder"><i class="fa-regular fa-sharp fa-cassette-tape sx"></i> Record stream<span id="menu-check-recorder"><i class="fa-solid fa-sharp fa-check"></i></span></a></li>
29092910
<li id="context-menu-multiroom-sender" class="hide"><a href="#notarget" data-cmd="multiroom_rx_modal"><i class="fa-regular fa-sharp fa-speakers sx"></i> Receivers</a></li>
29102911
<li id="context-menu-coverview-toggle" class="hide"><a href="#notarget" data-cmd="toggle_coverview"><i class="fa-regular fa-sharp fa-tv sx"></i> Toggle CoverView</a></li>

0 commit comments

Comments
 (0)