-
Notifications
You must be signed in to change notification settings - Fork 4
/
subsonic6.js
60 lines (44 loc) · 1.54 KB
/
subsonic6.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
Fluid App Userscript
Subsonic 6 web interface (HTML5 Player)
author: Ross Bates ([email protected])
usage: window.fluid.include('subsonic6.js');
*/
queue = parent.frames["playQueue"];
player = null;
/* can't get document DOMContentLoaded event in Fluid, falling back to this */
setTimeout(function(){ playerInit(); }, 5000);
function playerInit(){
window.console.log("Initilizing player extensions...");
player = queue.localPlayer; //html5 audio player embedded in the playQueue
window.fluid.addDockMenuItem("Next", goNext);
window.fluid.addDockMenuItem("Previous", goPrevious);
window.fluid.addDockMenuItem("Pause", togglePause);
//player.onPlay(function() {playerStarted();});
//player.onPause(function() {playerPaused();});
};
function playerStarted(){
//stub player start
};
function playerPaused(){
//stub player pause
};
/* detects playing state and toggles between play & pause */
function togglePause() {
getPlayerWindow().keyboardShortcut("togglePlayPause");
if (player.paused) {
window.fluid.removeDockMenuItem("Pause");
window.fluid.addDockMenuItem("Play", togglePause);
} else {
window.fluid.removeDockMenuItem("Play");
window.fluid.addDockMenuItem("Pause", togglePause);
}
};
/* move to previous song, returns null on first */
function goPrevious() {
getPlayerWindow().keyboardShortcut("previous");
};
/* move to next song in the queue, returns null on last */
function goNext() {
getPlayerWindow().keyboardShortcut("next");
};