]> git.donarmstrong.com Git - dactyl.git/blobdiff - melodactyl/content/player.js
Import r6948 from upstream hg supporting Firefox up to 24.*
[dactyl.git] / melodactyl / content / player.js
index 8eb8f1171092fa8326f05e1b06b6e6dcb3f45b9c..96e97a04254fdc8587b63282e0f6d7afeace4eef 100644 (file)
@@ -44,34 +44,35 @@ const Player = Module("player", {
         onMediacoreEvent: function (event) {
             switch (event.type) {
                 case Ci.sbIMediacoreEvent.BEFORE_TRACK_CHANGE:
-                    dactyl.log("Before track changed: " + event.data);
+                    dactyl.log(_("player.preTrackChange", event.data));
                     autocommands.trigger("TrackChangePre", { track: event.data });
                     break;
                 case Ci.sbIMediacoreEvent.TRACK_CHANGE:
+                    dactyl.log(_("player.trackChanged", event.data));
                     autocommands.trigger("TrackChange", { track: event.data });
                     break;
                 case Ci.sbIMediacoreEvent.BEFORE_VIEW_CHANGE:
-                    dactyl.log("Before view changed: " + event.data);
+                    dactyl.log(_("player.preViewChange", event.data));
                     autocommands.trigger("ViewChangePre", { view: event.data });
                     break;
                 case Ci.sbIMediacoreEvent.VIEW_CHANGE:
-                    dactyl.log("View changed: " + event.data);
+                    dactyl.log(_("player.viewChange", event.data));
                     autocommands.trigger("ViewChange", { view: event.data });
                     break;
                 case Ci.sbIMediacoreEvent.STREAM_START:
-                    dactyl.log("Track started: " + gMM.sequencer.currentItem);
+                    dactyl.log(_("player.trackStart", gMM.sequencer.currentItem));
                     autocommands.trigger("StreamStart", { track: gMM.sequencer.currentItem });
                     break;
                 case Ci.sbIMediacoreEvent.STREAM_PAUSE:
-                    dactyl.log("Track paused: " + gMM.sequencer.currentItem);
+                    dactyl.log(_("player.trackPause", gMM.sequencer.currentItem));
                     autocommands.trigger("StreamPause", { track: gMM.sequencer.currentItem });
                     break;
                 case Ci.sbIMediacoreEvent.STREAM_END:
-                    dactyl.log("Track ended: " + gMM.sequencer.currentItem);
+                    dactyl.log(_("player.trackEnd", gMM.sequencer.currentItem));
                     autocommands.trigger("StreamEnd", { track: gMM.sequencer.currentItem });
                     break;
                 case Ci.sbIMediacoreEvent.STREAM_STOP:
-                    dactyl.log("Track stopped: " + gMM.sequencer.currentItem);
+                    dactyl.log(_("player.trackStop", gMM.sequencer.currentItem));
                     autocommands.trigger("StreamStop", { track: gMM.sequencer.currentItem });
                     break;
             }
@@ -332,7 +333,7 @@ const Player = Module("player", {
     /**
      * Returns an array of all available playlists.
      *
-     * @returns {sbIMediaList[]}
+     * @returns {[sbIMediaList]}
      */
     getPlaylists: function getPlaylists() {
         let mainLibrary = LibraryUtils.mainLibrary;
@@ -366,7 +367,7 @@ const Player = Module("player", {
     /**
      * Returns an array of all available media pages.
      *
-     * @returns {sbIMediaPageInfo[]}
+     * @returns {[sbIMediaPageInfo]}
      */
     getMediaPages: function getMediaPages() {
         let list = SBGetBrowser().currentMediaPage.mediaListView.mediaList;
@@ -375,7 +376,7 @@ const Player = Module("player", {
     },
 
     /**
-     * Loads the the specified media page into *view* with the given *list* of
+     * Loads the specified media page into *view* with the given *list* of
      * media items.
      *
      * @param {sbIMediaPage} page
@@ -455,7 +456,7 @@ const Player = Module("player", {
         });
 
     },
-    commandline: function () {
+    commandline: function initCommandline() {
         player.CommandMode = Class("CommandSearchViewMode", modules.CommandMode, {
             init: function init(mode) {
                 this.mode = mode;
@@ -471,7 +472,7 @@ const Player = Module("player", {
             get onSubmit() player.closure.onSearchSubmit
         });
     },
-    commands: function () {
+    commands: function initCommands() {
         commands.add(["f[ilter]"],
                 "Filter tracks based on keywords {genre/artist/album/track}",
                 function (args) {
@@ -660,7 +661,7 @@ const Player = Module("player", {
                 let arg = args[0];
 
                 dactyl.assert(arg, _("error.argumentRequired"));
-                dactyl.assert(/^[+-]?\d+$/.test(arg), _("error.trailing"));
+                dactyl.assert(/^[+-]?\d+$/.test(arg), _("error.trailingCharacters"));
 
                 let level = parseInt(arg, 10) / 100;
 
@@ -671,7 +672,7 @@ const Player = Module("player", {
             },
             { argCount: "1" });
     },
-    completion: function () {
+    completion: function initCompletion() {
         completion.album = function album(context, artist) {
             context.title = ["Album"];
             context.completions = [[v, ""] for ([, v] in Iterator(library.getAlbums(artist)))];
@@ -707,14 +708,14 @@ const Player = Module("player", {
             context.completions = [[v, ""] for ([, v] in Iterator(library.getTracks(artist, album)))];
         };
     },
-    mappings: function () {
+    mappings: function initMappings() {
         mappings.add([modes.PLAYER],
             ["x"], "Play track",
             function () { ex.playerplay(); });
 
         mappings.add([modes.PLAYER],
             ["z"], "Previous track",
-            function (args) { ex.playerprev({ "#": args.count }); },
+            function ({ count }) { ex.playerprev({ "#": count }); },
             { count: true });
 
         mappings.add([modes.PLAYER],
@@ -723,7 +724,7 @@ const Player = Module("player", {
 
         mappings.add([modes.PLAYER],
             ["b"], "Next track",
-            function (args) { ex.playernext({ "#": args.count }); },
+            function ({ count }) { ex.playernext({ "#": count }); },
             { count: true });
 
         mappings.add([modes.PLAYER],
@@ -752,22 +753,22 @@ const Player = Module("player", {
 
         mappings.add([modes.PLAYER],
             ["h", "<Left>"], "Seek -10s",
-            function (args) { player.seekBackward(Math.max(1, args.count) * 10000); },
+            function ({ count} ) { player.seekBackward(Math.max(1, count) * 10000); },
             { count: true });
 
         mappings.add([modes.PLAYER],
             ["l", "<Right>"], "Seek +10s",
-            function (args) { player.seekForward(Math.max(1, args.count) * 10000); },
+            function ({ count} ) { player.seekForward(Math.max(1, count) * 10000); },
             { count: true });
 
         mappings.add([modes.PLAYER],
             ["H", "<S-Left>"], "Seek -1m",
-            function (args) { player.seekBackward(Math.max(1, args.count) * 60000); },
+            function ({ count }) { player.seekBackward(Math.max(1, count) * 60000); },
             { count: true });
 
         mappings.add([modes.PLAYER],
             ["L", "<S-Right>"], "Seek +1m",
-            function (args) { player.seekForward(Math.max(1, args.count) * 60000); },
+            function ({ count }) { player.seekForward(Math.max(1, count) * 60000); },
             { count: true });
 
         mappings.add([modes.PLAYER],
@@ -805,7 +806,7 @@ const Player = Module("player", {
             };
         }
     },
-    options: function () {
+    options: function initOptions() {
         options.add(["repeat"],
             "Set the playback repeat mode",
             "number", 0,
@@ -829,4 +830,4 @@ const Player = Module("player", {
     }
 });
 
-// vim: set fdm=marker sw=4 ts=4 et:
+// vim: set fdm=marker sw=4 sts=4 ts=8 et: