jmpInputPlugin.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. (async () => {
  20. const api = await window.apiPromise;
  21. api.input.hostInput.connect((actions) => {
  22. actions.forEach(action => {
  23. if (remap.hasOwnProperty(action)) {
  24. action = remap[action];
  25. }
  26. inputManager.handleCommand(action, {});
  27. });
  28. });
  29. api.system.hello("jmpInputPlugin");
  30. })();
  31. }
  32. }
  33. window._jmpInputPlugin = jmpInputPlugin;