Thank you for your donation!


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


One button / command to load & play random track?
#7
(02-27-2019, 04:16 PM)Tim Curtis Wrote: The web API only accepts MPD commands, vol.sh commands and <script>.sh commands where <script> is a user written script stored in /var/www

Yeah, so I'm looking at ways to trigger what happens when I click on the random button, ie this code in scripts-panels.js:

Code:
 $('.btn-toggle').click(function(e) {
               var id = $(this).attr('id');
               var cmd = id.startsWith('m') ? id.substr(1) : id;
               var toggle = $(this).hasClass('btn-primary') ? '0' : '1';
               if (cmd == 'random' && SESSION.json['ashufflesvc'] == '1') {
                       var resp = sendMoodeCmd('GET', 'ashuffle', {'ashuffle':toggle}); // toggle ashuffle on/off
                   $('random').toggleClass('btn-primary');
                   $('consume').toggleClass('btn-primary');
                       sendMpdCmd('consume ' + toggle);
               }
               else {
                   $(this).toggleClass('btn-primary');
                       sendMpdCmd(cmd + ' ' + toggle);
               }
Which is where the limits of my expertise are exposed - never having touched JS before.

One (perhaps the easiest?) approach could be to use puppeteer on my control device to run a headless browser with the Moode playback panel open, and simulate the click when called.
Reply


Messages In This Thread
RE: One button / command to load & play random track? - by tristanc - 03-02-2019, 10:58 AM

Forum Jump: