diff --git a/lib/actions/pauseall.js b/lib/actions/pauseall.js index 9312162e..a46f8d3f 100644 --- a/lib/actions/pauseall.js +++ b/lib/actions/pauseall.js @@ -58,8 +58,27 @@ function doResumeAll(system) { return Promise.all(promises); } +function anyPlayerOn(player, values) { + logger.debug("is any player on"); + + if (values[0] && values[0] > 0) { + setTimeout(function () { + doStateOn(player.system); + }, values[0] * 1000 * 60); + return Promise.resolve(); + } + + return doAnyPlayerOn(player.system); +} + +function doAnyPlayerOn(system) { + const promises = system.zones.some(zone => zone.coordinator.state.playbackState === 'PLAYING'); + return {promises}; +} + module.exports = function (api) { api.registerAction('pauseall', pauseAll); api.registerAction('resumeall', resumeAll); -} + api.registerAction('anyplayeron', anyPlayerOn); +} \ No newline at end of file diff --git a/static/index.html b/static/index.html index fc16b3d4..114fd8b6 100644 --- a/static/index.html +++ b/static/index.html @@ -32,6 +32,7 @@
GET /zones
GET /favorites
GET /playlists
+GET /anyplayeron