Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

Concept211 commented Oct 28, 2016

How do we use/implement this?

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