Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

PictureInPictureButton.js 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // @flow
  2. import { NativeModules, Platform } from 'react-native';
  3. import { PIP_ENABLED, getFeatureFlag } from '../../../base/flags';
  4. import { translate } from '../../../base/i18n';
  5. import { IconMenuDown } from '../../../base/icons';
  6. import { connect } from '../../../base/redux';
  7. import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
  8. import { isLocalVideoTrackDesktop } from '../../../base/tracks/functions';
  9. import { enterPictureInPicture } from '../actions';
  10. type Props = AbstractButtonProps & {
  11. /**
  12. * Whether Picture-in-Picture is enabled or not.
  13. */
  14. _enabled: boolean,
  15. /**
  16. * The redux {@code dispatch} function.
  17. */
  18. dispatch: Function
  19. };
  20. /**
  21. * An implementation of a button for entering Picture-in-Picture mode.
  22. */
  23. class PictureInPictureButton extends AbstractButton<Props, *> {
  24. accessibilityLabel = 'toolbar.accessibilityLabel.pip';
  25. icon = IconMenuDown;
  26. label = 'toolbar.pip';
  27. /**
  28. * Handles clicking / pressing the button.
  29. *
  30. * @protected
  31. * @returns {void}
  32. */
  33. _handleClick() {
  34. this.props.dispatch(enterPictureInPicture());
  35. }
  36. /**
  37. * Implements React's {@link Component#render()}.
  38. *
  39. * @inheritdoc
  40. * @returns {React$Node}
  41. */
  42. render() {
  43. return this.props._enabled ? super.render() : null;
  44. }
  45. }
  46. /**
  47. * Maps (parts of) the redux state to the associated props for the
  48. * {@code PictureInPictureButton} component.
  49. *
  50. * @param {Object} state - The Redux state.
  51. * @private
  52. * @returns {{
  53. * _enabled: boolean
  54. * }}
  55. */
  56. function _mapStateToProps(state): Object {
  57. const flag = Boolean(getFeatureFlag(state, PIP_ENABLED));
  58. let enabled = flag && !isLocalVideoTrackDesktop(state);
  59. // Override flag for Android, since it might be unsupported.
  60. if (Platform.OS === 'android' && !NativeModules.PictureInPicture.SUPPORTED) {
  61. enabled = false;
  62. }
  63. return {
  64. _enabled: enabled
  65. };
  66. }
  67. export default translate(connect(_mapStateToProps)(PictureInPictureButton));