Moode Forum
about cmd=playitem_next - Printable Version

+- Moode Forum (https://moodeaudio.org/forum)
+-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3)
+--- Forum: Support (https://moodeaudio.org/forum/forumdisplay.php?fid=7)
+--- Thread: about cmd=playitem_next (/showthread.php?tid=7464)



about cmd=playitem_next - Phil35 - 02-28-2025

Hello,

The command works very well for a single file.
H
owever, it seems not, or I didn't find how to do,  

how to play next not a single file, but a full album meaning a full directory?

Thank you

Phil



RE: about cmd=playitem_next - Tim Curtis - 02-28-2025

The "Play next" feature for a whole album is available in Tag and Album views.

ETA: If you want to specify a folder name in Tag/Album views use the search facility and specify

folder "FOLDER"

where FOLDER can be just the name of the folder or it can contain a path to the folder for example 
"AC DC/Back In Black"


RE: about cmd=playitem_next - Nutul - 02-28-2025

(02-28-2025, 09:15 PM)Tim Curtis Wrote: The "Play next" feature for a whole album is available in Tag and Album views.

ETA: If you want to specify a folder name in Tag/Album views use the search facility and specify

folder "FOLDER"

where FOLDER can be just the name of the folder or it can contain a path to the folder for example 
"AC DC/Back In Black"

I thought he was referring to some kind of API command... isn't that the case?


RE: about cmd=playitem_next - Phil35 - 03-01-2025

(02-28-2025, 11:20 PM)Nutul Wrote:
(02-28-2025, 09:15 PM)Tim Curtis Wrote: The "Play next" feature for a whole album is available in Tag and Album views.

ETA: If you want to specify a folder name in Tag/Album views use the search facility and specify

folder "FOLDER"

where FOLDER can be just the name of the folder or it can contain a path to the folder for example 
"AC DC/Back In Black"

I thought he was referring to some kind of API command... isn't that the case?

Hello,
Yes.
for example:
Code:
Working :   http://192.168.6.112/command/?cmd=playitem_next%20USB/Intenso/Musique/ABBA%20Gold%20-%20ABBA%20/01%20-%20ABBA%20-%20Dancing%20Queen.flac
Not Working :  http://192.168.6.112/command/?cmd=playitem_next%20USB/Intenso/Musique/ABBA%20Gold%20-%20ABBA
same for a m3u file : Not Working : http://192.168.6.112/command/?cmd=playitem_next%20USB/Intenso/Musique/ABBA\%20Gold\%20-\%20ABBA\%20/ABBA\%20-\%20ABBA\%20Gold.flac.m3u
Even if for both the answer is: {"info":"OK"}

It seems not possible to ask for a whole album nor a m3u file with http://moodle/command/?cmd=playitem_next

Thanks
Phil


RE: about cmd=playitem_next - Tim Curtis - 03-01-2025

Correct, the playitem_next API only supports adding single track or radio station.


RE: about cmd=playitem_next - Phil35 - 03-01-2025

Thank you.

is this a feasible option?

Phil


RE: about cmd=playitem_next - Tim Curtis - 03-01-2025

Prolly. I'll add to the TODO list but not sure when it will get priority.

Maybe another dev would like to take on the challenge.


RE: about cmd=playitem_next - Phil35 - 03-02-2025

Hello @Tim Curtis ,
It is in this file ./www/command/index.php right ?
I think a new command should be implemented playalbum_next ? may be? What is your advise / Thanks / Phil

case 'playitem_next':
$item = trim(getArgs($cmd));
$sock = getMpdSock();
// Turn off auto-shuffle
_openSessionReadOnly($dbh);
if ($_SESSION['ashuffle'] == '1') {
turnOffAutoShuffle($sock);
}
// Search the Queue for the item
$search = strpos($item, 'RADIO') !== false ? parseDelimFile(file_get_contents(MPD_MUSICROOT . $item), '=')['File1'] : $item;
$result = findInQueue($sock, 'file', $search);

if (isset($result['Pos'])) {
// Play already Queued item
sendMpdCmd($sock, 'play ' . $result['Pos']);
$resp = readMpdResp($sock);
} else {
// Otherwise play the item after adding it to the Queue
$status = getMpdStatus($sock);
$cmds = array(addItemToQueue($item));
if ($cmd[0] == 'play_item_next') {
$pos = isset($status['song']) ? $status['song'] + 1 : $status['playlistlength'];
array_push($cmds, 'move ' . $status['playlistlength'] . ' ' . $pos);
} else {
$pos = $status['playlistlength'];
}
array_push($cmds, 'play ' . $pos);
chainMpdCmds($sock, $cmds);
}

echo json_encode(array('info' => 'OK'));
break;


RE: about cmd=playitem_next - Tim Curtis - 03-02-2025

Yes thats the file for REST API commands.

As far as "album" goes you need to think about the group of tracks that makes up the album. For example in Tag or Album view, playing an album actually submits an array containing the album tracks to the Queue.

Have a look in scripts-library.js "play_group" and "Play_group_next"

Code:
// Click coverart context menu item
$('#context-menu-lib-album a').click(function(e) {
    UI.dbEntry[0] = $.isNumeric(UI.dbEntry[0]) ? UI.dbEntry[0] : 0;

    if (!$('.album-view-button').hasClass('active')) {
        $('#lib-song-' + (UI.dbEntry[0] + 1).toString()).removeClass('active');
        $('img.lib-coverart, #lib-coverart-meta-area').removeClass('active');
    }

   // Order the files according the the order of the albums
   var files = [];
   for (i = 0; i < filteredAlbums.length; i++) {
       for (j = 0; j < filteredSongs.length; j++) {
           if (filteredSongs[j].key == filteredAlbums[i].key) {
               files.push(filteredSongs[j].file);
           }
       }
   }
    //console.log('files= ' + JSON.stringify(files));

   switch ($(this).data('cmd')) {
       case 'add_group':
       case 'add_group_next':
           sendQueueCmd($(this).data('cmd'), files);
           notify(NOTIFY_TITLE_INFO, $(this).data('cmd'), NOTIFY_DURATION_SHORT);
           break;
       case 'play_group':
       case 'play_group_next':
              sendQueueCmd($(this).data('cmd'), files);
             break;

Folders on the other hand can be added to the Queue via the MPD "add" command and all the files in the folder will be automatically added. Playlists can be added to the Queue via the MPD "load" command.