Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

RemoteControl.js 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* global APP, config */
  2. import Controller from "./Controller";
  3. import Receiver from "./Receiver";
  4. /**
  5. * Implements the remote control functionality.
  6. */
  7. class RemoteControl {
  8. /**
  9. * Constructs new instance. Creates controller and receiver properties.
  10. * @constructor
  11. */
  12. constructor() {
  13. this.controller = new Controller();
  14. this.receiver = new Receiver();
  15. this.enabled = false;
  16. this.initialized = false;
  17. }
  18. /**
  19. * Initializes the remote control - checks if the remote control should be
  20. * enabled or not, initializes the API module.
  21. */
  22. init() {
  23. if(config.disableRemoteControl || this.initialized) {
  24. return;
  25. }
  26. this.initialized = true;
  27. APP.API.init({
  28. forceEnable: true,
  29. });
  30. this.controller.enable(true);
  31. }
  32. /**
  33. * Handles API event for support for executing remote control events into
  34. * the wrapper application.
  35. * @param {boolean} isSupported true if the receiver side is supported by
  36. * the wrapper application.
  37. */
  38. onRemoteControlSupported(isSupported) {
  39. if(isSupported && !config.disableRemoteControl) {
  40. this.enabled = true;
  41. if(this.initialized) {
  42. this.receiver.enable(true);
  43. }
  44. }
  45. }
  46. }
  47. export default new RemoteControl();