James Fator

Plex Player - Creating standalone media apps from web pages

07 April 2015

Plex Player Banner

The Google Music Mac (GMM) project has been really popular among people who use Google Play's All Access service. It's only a bit of code wrapped around a web page though, which means if other web apps behave similarly to the Google Play Music page, we can create a standalone app that takes advantage of the OS X media keys for that web page simply by replacing a URL.

Plex is a web app that has a very similar control interface to Google Play Music and has no media key support, so it is really easy to adapt to the GMM wrapper. Now, before I go any further, I must mention that this is no amazing framework -- it's a hack off an existing project. This post is for people who are interested in creating an OS X app for whatever web-based media player they use.

On GitHub there's a branch off of GMM dedicated to the "Plex Player". The changes in the commit history are 99% updates to the title and icon, so there's really only a one line change that got Plex to work. Line 47 of the "AppDelegate.m" file is where the URL is entered. Changing this URL will change the web page the app loads up.

The Plex web app uses "space" to pause/play, "right" to skip forward, and "left" to skip backwards. This is the same control scheme that Google Play Music uses, so we're able to control Plex immediately. Not all web apps will act that way though and some tweaking may be required. In the "AppDelegate.m" file, there are 3 functions that are pretty self explanatory: playPause, forwardAction, and backAction. Those functions sent simulated key presses to the web app. If your web app doesn't use the same scheme, yet it can still be controlled with the keyboard, the existing code can be updated with the needed key strokes. This may be as easy as replacing one key press (key code) for another, or it may be difficult and require a modifier key (ctrl, alt, cmd). Most times what you're looking for is a Google search away, but feel free to email me if you have any questions.

There's bound to be more web apps out there that could use native OS X media key support, so this might be a solution for you.

If you like GMM, check out it's bigger, better looking brother: Radiant Player