Skip to content

Commit

Permalink
Merge pull request #14 from s00500/playPauseBackForward
Browse files Browse the repository at this point in the history
WIP: Play pause back forward
  • Loading branch information
LukeSkywalker92 authored May 4, 2019
2 parents 9852e19 + 5878764 commit 707f46a
Show file tree
Hide file tree
Showing 5 changed files with 325 additions and 207 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ The following properties can be configured:
| `toggleMonitor` | When set to true, TeleFrame will switch the monitor off and on at the defined hours. |
| `turnOnHour` | Defines when the monitor shuld be turned on. |
| `turnOffHour` | Defines when the monitor shuld be turned off. |
| `keys` | Defines an object with 4 strings specifying the keyboard shortcuts for play, next, previous and pause. Set to null for no controls |

## Whitelist Chats

Expand Down
8 changes: 7 additions & 1 deletion config/config.js.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ var config = {
showCaption: true,
toggleMonitor: true,
turnOnHour: 9,
turnOffHour: 22
turnOffHour: 22,
keys: {
next: "right",
previous: "left",
play: "l",
pause: "k"
}
};

/*************** DO NOT EDIT THE LINE BELOW ***************/
Expand Down
37 changes: 37 additions & 0 deletions js/inputHandler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const { globalShortcut } = require("electron");

var InputHandler = class {
constructor(config, emitter, logger) {
this.config = config;
this.logger = logger;
this.emitter = emitter;
}

init() {
if(config.keys === null) {
this.logger.warn("Keyboard controls are disabeled")
return;
}

globalShortcut.register(config.keys.next, () => {
this.emitter.send("next");
});

globalShortcut.register(config.keys.previous, () => {
this.emitter.send("previous");
});

globalShortcut.register(config.keys.pause, () => {
this.emitter.send("pause");
});

globalShortcut.register(config.keys.play, () => {
this.emitter.send("play");
});
}
};

/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {
module.exports = InputHandler;
}
Loading

0 comments on commit 707f46a

Please sign in to comment.