-
-
Notifications
You must be signed in to change notification settings - Fork 378
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): Change the interface of the SpeakerVolumeControlCapabilit…
…y and add the SpeakerTestCapability
- Loading branch information
Showing
9 changed files
with
65 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const Capability = require("./Capability"); | ||
const NotImplementedError = require("../NotImplementedError"); | ||
|
||
|
||
/* | ||
Plays some kind of sound to test the current audio volume | ||
*/ | ||
class SpeakerTestCapability extends Capability { | ||
/** | ||
* @abstract | ||
* @returns {Promise<void>} | ||
*/ | ||
async playTestSound() { | ||
throw new NotImplementedError(); | ||
} | ||
|
||
getType() { | ||
return SpeakerTestCapability.TYPE; | ||
} | ||
} | ||
|
||
SpeakerTestCapability.TYPE = "SpeakerTestCapability"; | ||
|
||
module.exports = SpeakerTestCapability; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
lib/webserver/capabilityRouters/SpeakerTestCapabilityRouter.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const Logger = require("../../Logger"); | ||
|
||
const CapabilityRouter = require("./CapabilityRouter"); | ||
|
||
class SpeakerTestCapabilityRouter extends CapabilityRouter { | ||
|
||
initRoutes() { | ||
this.router.put("/", async (req, res) => { | ||
if (req.body && req.body.action === "play_test_sound") { | ||
try { | ||
await this.capability.playTestSound(); | ||
res.sendStatus(200); | ||
} catch (e) { | ||
Logger.warn("Error while playing speaker test sound", e); | ||
res.status(500).json(e.message); | ||
} | ||
} else { | ||
res.status(400).send("Missing or invalid request body"); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
module.exports = SpeakerTestCapabilityRouter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters