Skip to content

Commit

Permalink
Add support for media buttons. (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
FelicianoTech authored Mar 9, 2019
1 parent 9641411 commit 26b6b75
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const electron = require( "electron" );
const { shell, app, BrowserWindow } = electron;
const { shell, app, BrowserWindow, globalShortcut } = electron;
const HOMEPAGE = "https://play.pocketcasts.com/web/"

let mainWindow;
Expand All @@ -25,6 +25,17 @@ app.on( "ready", () => {
}
});

// Register media controls
globalShortcut.register( 'MediaPlayPause', () => {
window.webContents.executeJavaScript( "document.querySelector( '.play_pause_button' ).click()");
});
globalShortcut.register( 'MediaPreviousTrack', () => {
window.webContents.executeJavaScript( "document.querySelector( '.skip_back_button' ).click()");
});
globalShortcut.register( 'MediaNextTrack', () => {
window.webContents.executeJavaScript( "document.querySelector( '.skip_forward_button' ).click()");
});

window.on( "closed", () => {
window = null;
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pocket-casts",
"version": "0.1.2",
"version": "0.2.0",
"description": "Pocket Casts is one of the best podcast / podcatchers out there. This is their webapp packaged as a desktop app. The actual webapp itself is the official code from Pocket Casts/NPR. This snap was packaged by Ricardo N Feliciano (FelicianoTech).",
"homepage": "https://github.com/felicianotech/pocket-casts-desktop-app",
"license": "MIT",
Expand Down

0 comments on commit 26b6b75

Please sign in to comment.