Home Reference Source

js/controls/device-button.js

  1. /**
  2. * @file device-button.js
  3. * @since 2.0.0
  4. */
  5.  
  6. import videojs from 'video.js';
  7.  
  8. const Button = videojs.getComponent('Button');
  9. const Component = videojs.getComponent('Component');
  10.  
  11. /**
  12. * Button to select recording device.
  13. *
  14. * @class
  15. * @augments videojs.Button
  16. */
  17. class DeviceButton extends Button {
  18. /**
  19. * This gets called when this button gets:
  20. *
  21. * - Clicked (via the `click` event, listening starts in the constructor)
  22. * - Tapped (via the `tap` event, listening starts in the constructor)
  23. *
  24. * @param {EventTarget~Event} event
  25. * The `keydown`, `tap`, or `click` event that caused this function to be
  26. * called.
  27. *
  28. * @listens tap
  29. * @listens click
  30. */
  31. handleClick(event) {
  32. // open device dialog
  33. this.player_.record().getDevice();
  34. }
  35.  
  36. /**
  37. * Show the `DeviceButton` element if it is hidden by removing the
  38. * 'vjs-hidden' class name from it.
  39. */
  40. show() {
  41. if (this.layoutExclude && this.layoutExclude === true) {
  42. // ignore
  43. return;
  44. }
  45. super.show();
  46. }
  47. }
  48.  
  49. /**
  50. * The text that should display over the `DeviceButton`s controls. Added for localization.
  51. *
  52. * @type {string}
  53. * @private
  54. */
  55. DeviceButton.prototype.controlText_ = 'Device';
  56.  
  57. Component.registerComponent('DeviceButton', DeviceButton);
  58.  
  59. export default DeviceButton;