mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-04 02:45:46 +01:00
Move some inline functionality to slots of player.
This commit is contained in:
@@ -11,122 +11,70 @@ function Player() // {{{
|
|||||||
// Get the focus to the visible playlist first
|
// Get the focus to the visible playlist first
|
||||||
//window._SBShowMainLibrary();
|
//window._SBShowMainLibrary();
|
||||||
|
|
||||||
|
// FIXME: need to test that we're playing - why is gMM.playbackControl.status always null?
|
||||||
|
// interval (seconds)
|
||||||
|
function seek(interval, direction)
|
||||||
|
{
|
||||||
|
interval = interval * 1000;
|
||||||
|
|
||||||
|
let min = 0;
|
||||||
|
let max = gMM.playbackControl.duration;
|
||||||
|
let position = gMM.playbackControl.position + (direction ? interval : -interval);
|
||||||
|
|
||||||
|
gMM.playbackControl.position = Math.min(Math.max(position, min), max)
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}}}
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
////////////////////// MAPPINGS ////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
mappings.add([modes.PLAYER],
|
mappings.add([modes.PLAYER],
|
||||||
["x"], "Play Track",
|
["x"], "Play Track",
|
||||||
function ()
|
function () { player.play(); });
|
||||||
{
|
|
||||||
gMM.sequencer.play();
|
|
||||||
});
|
|
||||||
|
|
||||||
mappings.add([modes.PLAYER],
|
mappings.add([modes.PLAYER],
|
||||||
["z"], "Previous Track",
|
["z"], "Previous Track",
|
||||||
function ()
|
function () { player.previous(); });
|
||||||
{
|
|
||||||
gSongbirdWindowController.doCommand("cmd_control_previous");
|
|
||||||
});
|
|
||||||
|
|
||||||
mappings.add([modes.PLAYER],
|
mappings.add([modes.PLAYER],
|
||||||
["c"], "Pause/Unpause Track",
|
["c"], "Pause/Unpause Track",
|
||||||
function ()
|
function () { player.togglePlayPause(); });
|
||||||
{
|
|
||||||
gSongbirdWindowController.doCommand("cmd_control_playpause");
|
|
||||||
});
|
|
||||||
|
|
||||||
mappings.add([modes.PLAYER],
|
mappings.add([modes.PLAYER],
|
||||||
["b"], "Next Track",
|
["b"], "Next Track",
|
||||||
function ()
|
function () { player.next(); });
|
||||||
{
|
|
||||||
gSongbirdWindowController.doCommand("cmd_control_next");
|
|
||||||
});
|
|
||||||
|
|
||||||
mappings.add([modes.PLAYER],
|
mappings.add([modes.PLAYER],
|
||||||
["v"], "Stop Track",
|
["v"], "Stop Track",
|
||||||
function ()
|
function () { player.stop(); });
|
||||||
{
|
|
||||||
gMM.sequencer.stop();
|
|
||||||
});
|
|
||||||
|
|
||||||
mappings.add([modes.PLAYER],
|
mappings.add([modes.PLAYER],
|
||||||
["f"], "Filter Library",
|
["f"], "Filter Library",
|
||||||
function ()
|
function () { commandline.open(":", "filter ", modes.EX); });
|
||||||
{
|
|
||||||
commandline.open(":", "filter ", modes.EX);
|
|
||||||
});
|
|
||||||
|
|
||||||
mappings.add([modes.PLAYER],
|
mappings.add([modes.PLAYER],
|
||||||
["s"], "Toggle Shuffle",
|
["s"], "Toggle Shuffle",
|
||||||
function ()
|
function () { player.toggleShuffle(); });
|
||||||
{
|
|
||||||
if (gMM.sequencer.mode != gMM.sequencer.MODE_SHUFFLE)
|
|
||||||
gMM.sequencer.mode = gMM.sequencer.MODE_SHUFFLE;
|
|
||||||
else
|
|
||||||
gMM.sequencer.mode = gMM.sequencer.MODE_FORWARD;
|
|
||||||
});
|
|
||||||
|
|
||||||
mappings.add([modes.PLAYER],
|
mappings.add([modes.PLAYER],
|
||||||
["r"], "Toggle Repeat",
|
["r"], "Toggle Repeat",
|
||||||
function ()
|
function () { player.toggleRepeat(); });
|
||||||
{
|
|
||||||
switch (gMM.sequencer.repeatMode)
|
|
||||||
{
|
|
||||||
case gMM.sequencer.MODE_REPEAT_NONE:
|
|
||||||
gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_ONE;
|
|
||||||
break;
|
|
||||||
case gMM.sequencer.MODE_REPEAT_ONE:
|
|
||||||
gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_ALL;
|
|
||||||
break;
|
|
||||||
case gMM.sequencer.MODE_REPEAT_ALL:
|
|
||||||
gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_NONE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_NONE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
mappings.add([modes.PLAYER],
|
mappings.add([modes.PLAYER],
|
||||||
["h"], "Seek -10s",
|
["h"], "Seek -10s",
|
||||||
function ()
|
function () { player.seekBackward(10); });
|
||||||
{
|
|
||||||
if (gMM.playbackControl.position >= 10000)
|
|
||||||
gMM.playbackControl.position = gMM.playbackControl.position - 10000;
|
|
||||||
else
|
|
||||||
gMM.playbackControl.position = 0;
|
|
||||||
});
|
|
||||||
|
|
||||||
mappings.add([modes.PLAYER],
|
mappings.add([modes.PLAYER],
|
||||||
["l"], "Seek +10s",
|
["l"], "Seek +10s",
|
||||||
function ()
|
function () { player.seekForward(10); });
|
||||||
{
|
|
||||||
if ((gMM.playbackControl.duration - gMM.playbackControl.position) >= 10000)
|
|
||||||
gMM.playbackControl.position = gMM.playbackControl.position + 10000;
|
|
||||||
else
|
|
||||||
gMM.playbackControl.position = gMM.playbackControl.duration;
|
|
||||||
});
|
|
||||||
|
|
||||||
mappings.add([modes.PLAYER],
|
mappings.add([modes.PLAYER],
|
||||||
["H"], "Seek -1m",
|
["H"], "Seek -1m",
|
||||||
function ()
|
function () { player.seekBackward(60); });
|
||||||
{
|
|
||||||
if (gMM.playbackControl.position >= 60000)
|
|
||||||
gMM.playbackControl.position = gMM.playbackControl.position - 60000;
|
|
||||||
else
|
|
||||||
gMM.playbackControl.position = 0;
|
|
||||||
});
|
|
||||||
|
|
||||||
mappings.add([modes.PLAYER],
|
mappings.add([modes.PLAYER],
|
||||||
["L"], "Seek +1m",
|
["L"], "Seek +1m",
|
||||||
function ()
|
function () { player.seekForward(60); });
|
||||||
{
|
|
||||||
if ((gMM.playbackControl.duration - gMM.playbackControl.position) >= 60000)
|
|
||||||
gMM.playbackControl.position = gMM.playbackControl.position + 60000;
|
|
||||||
else
|
|
||||||
gMM.playbackControl.position = gMM.playbackControl.duration;
|
|
||||||
});
|
|
||||||
|
|
||||||
////////////////// ///////////////////////////////////////////////////////////}}}
|
////////////////// ///////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// COMMANDS ////////////////////////////////////////////////
|
////////////////////// COMMANDS ////////////////////////////////////////////////
|
||||||
@@ -137,11 +85,11 @@ function Player() // {{{
|
|||||||
function (args)
|
function (args)
|
||||||
{
|
{
|
||||||
//Store the old view
|
//Store the old view
|
||||||
//var prev_view = gMM.status.view;
|
//let prev_view = gMM.status.view;
|
||||||
var library = LibraryUtils.mainLibrary;
|
let library = LibraryUtils.mainLibrary;
|
||||||
var mainView = library.createView();
|
let mainView = library.createView();
|
||||||
var sqncr = gMM.sequencer;
|
let sqncr = gMM.sequencer;
|
||||||
var customProps = Cc["@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"]
|
let customProps = Cc["@songbirdnest.com/Songbird/Properties/MutablePropertyArray;1"]
|
||||||
.createInstance(Ci.sbIMutablePropertyArray);
|
.createInstance(Ci.sbIMutablePropertyArray);
|
||||||
|
|
||||||
//args
|
//args
|
||||||
@@ -164,10 +112,76 @@ function Player() // {{{
|
|||||||
completer: function (context, args) completion.song(context, args)
|
completer: function (context, args) completion.song(context, args)
|
||||||
});
|
});
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////}} }
|
/////////////////////////////////////////////////////////////////////////////}}}
|
||||||
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
////////////////////// PUBLIC SECTION //////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
|
|
||||||
|
return {
|
||||||
|
|
||||||
|
play: function play()
|
||||||
|
{
|
||||||
|
gMM.sequencer.play();
|
||||||
|
},
|
||||||
|
|
||||||
|
stop: function stop()
|
||||||
|
{
|
||||||
|
gMM.sequencer.stop();
|
||||||
|
},
|
||||||
|
|
||||||
|
next: function next()
|
||||||
|
{
|
||||||
|
gSongbirdWindowController.doCommand("cmd_control_next");
|
||||||
|
},
|
||||||
|
|
||||||
|
previous: function previous()
|
||||||
|
{
|
||||||
|
gSongbirdWindowController.doCommand("cmd_control_previous");
|
||||||
|
},
|
||||||
|
|
||||||
|
togglePlayPause: function togglePlayPause()
|
||||||
|
{
|
||||||
|
gSongbirdWindowController.doCommand("cmd_control_playpause");
|
||||||
|
},
|
||||||
|
|
||||||
|
toggleShuffle: function toggleShuffle()
|
||||||
|
{
|
||||||
|
if (gMM.sequencer.mode != gMM.sequencer.MODE_SHUFFLE)
|
||||||
|
gMM.sequencer.mode = gMM.sequencer.MODE_SHUFFLE;
|
||||||
|
else
|
||||||
|
gMM.sequencer.mode = gMM.sequencer.MODE_FORWARD;
|
||||||
|
},
|
||||||
|
|
||||||
|
// FIXME: not really toggling - good enough for now.
|
||||||
|
toggleRepeat: function toggleRepeat()
|
||||||
|
{
|
||||||
|
switch (gMM.sequencer.repeatMode)
|
||||||
|
{
|
||||||
|
case gMM.sequencer.MODE_REPEAT_NONE:
|
||||||
|
gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_ONE;
|
||||||
|
break;
|
||||||
|
case gMM.sequencer.MODE_REPEAT_ONE:
|
||||||
|
gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_ALL;
|
||||||
|
break;
|
||||||
|
case gMM.sequencer.MODE_REPEAT_ALL:
|
||||||
|
gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_NONE;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_NONE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
seekForward: function seekForward(interval)
|
||||||
|
{
|
||||||
|
seek(interval, true);
|
||||||
|
},
|
||||||
|
|
||||||
|
seekBackward: function seekBackward(interval)
|
||||||
|
{
|
||||||
|
seek(interval, false);
|
||||||
|
},
|
||||||
|
|
||||||
|
};
|
||||||
//}}}
|
//}}}
|
||||||
} // }}}
|
} // }}}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user