Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Idea: API Candidate
#11
(01-06-2024, 04:55 PM)Tim Curtis Wrote: I just got a moment to look at this and there is prolly an easier and more flexible way to get MPD command output.

In file /var/www/command/index.php the code block below can be modified to return output from any MPD command. Some commamds return output that can be parsed by the general purpose parseDelimFile() routine but others require a custom parsing routine for example lsinfo, playlistinfo, etc, and so additional code is needed.

A feature implementation would be something like:
- An option to turn ON/OFF the feature
- Encapsulate the code in inc/<name>.php
- Conditional in command/index.php: if feature is on then parsrMpdOutput()

Example:

Code:
    } else {
        // MPD commands
        if (false === ($sock = openMpdSock('localhost', 6600))) {
            workerLog('command/index.php: Connection to MPD failed');
        } else {
            sendMpdCmd($sock, $_GET['cmd']);
            $resp = readMpdResp($sock);
            closeMpdSock($sock);

            echo json_encode(parseDelimFile($resp, ': '));

            /*if (stripos($resp, 'Error:')) {
                echo $resp;
            }*/
        }
    }

Output:
http://moode/command/?cmd=status

Code:
{"volume":"55","repeat":"0","random":"0","single":"0","consume":"0","partition":"default","playlist":"40","playlistlength":"34","mixrampdb":"0","state":"play","song":"5","songid":"6","time":"254:0","elapsed":"253.711","bitrate":"128","audio":"44100:24:2","nextsong":"6","nextsongid":"7"}

Patching that in does allow me to load a playlist and start it playing at a specific track, which helps.  mpc rejects cmd=lsplaylists as an argument.  That's really all I'd need to be able to automate the music playback throughout the house.

Would you consider adding general mpc coverage into a future release?
Reply
#12
Sure no prob. I can prolly slip this in for upcoming 8.3.8 release (early Q1 2024).
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#13
(01-06-2024, 06:26 PM)Tim Curtis Wrote: Sure no prob. I can prolly slip this in for upcoming 8.3.8 release (early Q1 2024).

Thanks, Tim.  I can retire from coding, now!  Smile
Reply


Forum Jump: