-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules/ | ||
Pandora-*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Pandora App | ||
|
||
This uses Nativefier (https://github.com/jiahaog/nativefier) to build a native | ||
app for running Pandora on a desktop. It provides support for playing and | ||
pausing using the play/pause button on the keyboard no matter if the app has | ||
the focus or not. | ||
|
||
## Building | ||
|
||
Install Nativefier according to its instructions. | ||
|
||
```shell | ||
npm install nativefier -g | ||
``` | ||
|
||
Install Google Chrome if you don't already have it (its Flash plugin is | ||
required). | ||
|
||
In Chrome, find the path to the Flash plugin by typing `chrome://plugins` in | ||
the location bar. | ||
|
||
Edit `build.sh` and update the `FLASH` variable with the location of your Flash | ||
plugin. | ||
|
||
```shell | ||
./build.sh | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
# Update Flash path whenever Flash updated. | ||
# Enter chrome://plugins in Chrome to find location. | ||
export FLASH="/Users/tim/Library/Application Support/Google/Chrome/PepperFlash/24.0.0.186/PepperFlashPlayer.plugin" | ||
|
||
nativefier --name Pandora --flash --flash-path "$FLASH" --inject pandora.js "http://pandora.com" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Connect the play/pause button to Pandora. | ||
ipc = require('electron').ipcRenderer; | ||
globalShortcut = require('electron').remote.globalShortcut; | ||
BrowserWindow = require('electron').remote.BrowserWindow; | ||
|
||
// Ensure a reload event doesn't leave references to garbage collected | ||
// functions. | ||
globalShortcut.unregisterAll(); | ||
|
||
// Send the key press to the play-pause channel of the Pandora window. | ||
function sendKey() { | ||
var mainWindow = BrowserWindow.getAllWindows()[0]; | ||
mainWindow.webContents.send('play-pause'); | ||
} | ||
|
||
globalShortcut.register('MediaPlayPause', sendKey); | ||
|
||
// Also use Ctrl-Shift-1 as a backup if the keyboard doesn't have a | ||
// play/pause button. | ||
globalShortcut.register('ctrl+shift+1', sendKey); | ||
|
||
// Subscribe to the play-pause channel in the renderer process. | ||
ipc.on('play-pause', function () { | ||
var pauseBtn = document.getElementsByClassName('pauseButton')[0]; | ||
var child; | ||
if(pauseBtn.style.display === 'block') { | ||
child = pauseBtn.childNodes[0]; | ||
} else { | ||
var playBtn = document.getElementsByClassName('playButton')[0]; | ||
child = playBtn.childNodes[0]; | ||
} | ||
child.click(); | ||
}); |