Skip to content

Instantly share code, notes, and snippets.

@utgwkk
Created April 2, 2016 03:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save utgwkk/39c0482e2faeb37baf09f0dea14188ae to your computer and use it in GitHub Desktop.
Save utgwkk/39c0482e2faeb37baf09f0dea14188ae to your computer and use it in GitHub Desktop.
Enables to control your Subsonic with Media Key.
// ==UserScript==
// @name Media Key for Subsonic 5
// @namespace http://utgw.net/
// @version 0.1
// @description Enables to control your Subsonic with Media Key.
// @author utgwkk
// @match https?://*/subsonic/index.view
// @require https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.6.15/browser-polyfill.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.6.15/browser.min.js
// ==/UserScript==
/* jshint ignore:start */
var inline_src = (<><![CDATA[
/* jshint ignore:end */
/* jshint esnext: true */
(()=>{
window.addEventListener('load', ()=>{
const pf = document.getElementsByClassName('bgcolor2')[2];
const cw = pf.contentWindow;
const jw = cw.jwplayer;
window.addEventListener('keydown', (evt)=>{
if(evt.keyCode == 179){ // play/pause
const state = jw().getState();
if(state == "PLAYING"){
jw().pause();
}else if(state == "PAUSED"){
jw().play();
}
}else if(evt.keyCode == 39 || evt.keyCode == 176){
cw.onNext();
}else if(evt.keyCode == 37 || evt.keyCode == 177){
cw.onPrevious();
}
});
});
})();
/* jshint ignore:start */
]]></>).toString();
var c = babel.transform(inline_src);
eval(c.code);
/* jshint ignore:end */
@Concept211
Copy link

How do we use/implement this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment