Skip to content

Commit

Permalink
Update Media Plugin to API V2
Browse files Browse the repository at this point in the history
  • Loading branch information
atticuscornett committed Jun 6, 2024
1 parent 315dc43 commit 363625c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion public/bundled-plugins/media-controls/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Media Controls Plugin
##### This is a built-in mimacro plugin built by the mimacro team.
##### Built-in plugins are found in the `bundled-plugins` folder and do not display on the plugins page.
### Adds mouse controls to mimacro using nutjs and node-loudness.
### Adds media controls to mimacro using robotjs and node-loudness.
14 changes: 7 additions & 7 deletions public/bundled-plugins/media-controls/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const {keyboard, Key} = use("@nut-tree/nut-js");
const robotjs = use("@jitsi/robotjs");
const loudness = use("loudness");
let thisPlugin;
function onEnable(plugin){
Expand Down Expand Up @@ -66,22 +66,22 @@ function onGetActions(){
async function onAction(actionId, metadata, value) {
console.log(value);
if (actionId === "playMedia") {
await keyboard.type(Key.AudioPlay);
robotjs.keyTap("audio_play");
}
if (actionId === "muteMedia"){
await keyboard.type(Key.AudioMute);
robotjs.keyTap("audio_mute");
}
if (actionId === "volUp"){
await keyboard.type(Key.AudioVolUp);
robotjs.keyTap("audio_vol_up");
}
if (actionId === "volDown"){
await keyboard.type(Key.AudioVolDown);
robotjs.keyTap("audio_vol_down");
}
if (actionId === "nextSong"){
await keyboard.type(Key.AudioNext);
robotjs.keyTap("audio_next");
}
if (actionId === "prevSong"){
await keyboard.type(Key.AudioPrev);
robotjs.keyTap("audio_prev");
}
if (actionId === "volDial"){
let volume = Math.floor(value*100);
Expand Down
3 changes: 2 additions & 1 deletion public/bundled-plugins/media-controls/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "builtin-media-controls",
"displayName": "Media Controls",
"version": "0.0.1",
"version": "0.0.2",
"pluginAPIVersion": 2,
"description": "Media controls for mimacro",
"main": "index.js",
"icon": "icon.svg",
Expand Down

0 comments on commit 363625c

Please sign in to comment.