Adding routes for a REST api /playback/:action
This commit is contained in:
parent
2c2b630d34
commit
34a98a6513
1 changed files with 21 additions and 0 deletions
|
@ -150,6 +150,27 @@ export class BrowserWindow {
|
|||
res.render("main", this.EnvironmentVariables);
|
||||
});
|
||||
|
||||
app.get("/playback/:action", (req, res)=>{
|
||||
const action = req.params.action;
|
||||
switch(action) {
|
||||
case "play":
|
||||
BrowserWindow.win.webContents.executeJavaScript("MusicKit.getInstance().play()")
|
||||
res.send("Playing")
|
||||
break;
|
||||
case "pause":
|
||||
BrowserWindow.win.webContents.executeJavaScript("MusicKit.getInstance().pause()")
|
||||
res.send("Paused")
|
||||
break;
|
||||
case "stop":
|
||||
BrowserWindow.win.webContents.executeJavaScript("MusicKit.getInstance().stop()")
|
||||
res.send("Stopped")
|
||||
break;
|
||||
default: {
|
||||
res.send("Invalid action")
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
app.get("/themes/:theme", (req, res) => {
|
||||
const theme = req.params.theme.toLowerCase();
|
||||
const themePath = path.join(utils.getPath('srcPath'), "./renderer/themes/", theme);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue