media.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. "use strict";
  5. const {Ci} = require("chrome");
  6. const l10n = require("gcli/l10n");
  7. function getContentViewer(context) {
  8. let {window} = context.environment;
  9. return window.QueryInterface(Ci.nsIInterfaceRequestor)
  10. .getInterface(Ci.nsIDocShell)
  11. .contentViewer;
  12. }
  13. exports.items = [
  14. {
  15. name: "media",
  16. description: l10n.lookup("mediaDesc")
  17. },
  18. {
  19. item: "command",
  20. runAt: "server",
  21. name: "media emulate",
  22. description: l10n.lookup("mediaEmulateDesc"),
  23. manual: l10n.lookup("mediaEmulateManual"),
  24. params: [
  25. {
  26. name: "type",
  27. description: l10n.lookup("mediaEmulateType"),
  28. type: {
  29. name: "selection",
  30. data: [
  31. "braille", "embossed", "handheld", "print", "projection",
  32. "screen", "speech", "tty", "tv"
  33. ]
  34. }
  35. }
  36. ],
  37. exec: function(args, context) {
  38. let contentViewer = getContentViewer(context);
  39. contentViewer.emulateMedium(args.type);
  40. }
  41. },
  42. {
  43. item: "command",
  44. runAt: "server",
  45. name: "media reset",
  46. description: l10n.lookup("mediaResetDesc"),
  47. exec: function(args, context) {
  48. let contentViewer = getContentViewer(context);
  49. contentViewer.stopEmulatingMedium();
  50. }
  51. }
  52. ];