Adding routes for a REST api /playback/:action

This commit is contained in:
booploops 2022-02-03 19:26:59 -08:00
parent 2c2b630d34
commit 34a98a6513

View file

@ -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);