Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New endpoint to show if any speaker is running #781

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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