Created
April 2, 2016 03:50
-
-
Save utgwkk/39c0482e2faeb37baf09f0dea14188ae to your computer and use it in GitHub Desktop.
Enables to control your Subsonic with Media Key.
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
// ==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 */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How do we use/implement this?