Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion lib/actions/pauseall.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of this setTimeout?


return doAnyPlayerOn(player.system);
}

function doAnyPlayerOn(system) {
const promises = system.zones.some(zone => zone.coordinator.state.playbackState === 'PLAYING');
return {promises};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing here is a promise, so not sure why you return an object with { promises: bool }

}


module.exports = function (api) {
api.registerAction('pauseall', pauseAll);
api.registerAction('resumeall', resumeAll);
}
api.registerAction('anyplayeron', anyPlayerOn);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be in it's own action file, since it doesn't really have anything to do with play/pause all functionality.

}
1 change: 1 addition & 0 deletions static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ <h2>Info</h2>
<p><span class="method">GET</span> <a href="/zones">/zones</a></p>
<p><span class="method">GET</span> <a href="/favorites">/favorites</a></p>
<p><span class="method">GET</span> <a href="/playlists">/playlists</a></p>
<p><span class="method">GET</span> <a href="/anyplayeron">/anyplayeron</a></p>
</div>

<div class="docs">
Expand Down