jmpInputPlugin.js 976 B

12345678910111213141516171819202122232425262728293031323334
  1. const remap = {
  2. "play_pause": "playpause",
  3. "seek_forward": "fastforward",
  4. "seek_backward": "rewind",
  5. "host:fullscreen": "togglefullscreen",
  6. "cycle_audio": "changeaudiotrack",
  7. "cycle_subtitles": "changesubtitletrack",
  8. "increase_volume": "volumeup",
  9. "decrease_volume": "volumedown",
  10. "step_backward": "previouschapter",
  11. "step_forward": "nextchapter",
  12. "enter": "select",
  13. }
  14. class jmpInputPlugin {
  15. constructor({ inputManager }) {
  16. this.name = 'JMP Input Plugin';
  17. this.type = 'input';
  18. this.id = 'jmpInputPlugin';
  19. window.api.input.hostInput.connect((actions) => {
  20. actions.forEach(action => {
  21. if (remap.hasOwnProperty(action)) {
  22. action = remap[action];
  23. }
  24. inputManager.handleCommand(action, {});
  25. });
  26. });
  27. window.api.system.hello("jmpInputPlugin");
  28. }
  29. }
  30. window._jmpInputPlugin = jmpInputPlugin;