Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

actions.js 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // @flow
  2. import { NativeModules } from 'react-native';
  3. import { Platform } from '../../base/react';
  4. import { ENTER_PICTURE_IN_PICTURE } from './actionTypes';
  5. /**
  6. * Enters (or rather initiates entering) picture-in-picture.
  7. * Helper function to enter PiP mode. This is triggered by user request
  8. * (either pressing the button in the toolbox or the home button on Android)
  9. * ans this triggers the PiP mode, iff it's available and we are in a
  10. * conference.
  11. *
  12. * @public
  13. * @returns {Function}
  14. */
  15. export function enterPictureInPicture() {
  16. return (dispatch: Dispatch, getState: Function) => {
  17. const state = getState();
  18. const { app } = state['features/app'];
  19. // FIXME We want to be able to enter Picture-in-Picture as soon as we
  20. // are on the Conference page i.e. even before `joining` was set in the
  21. // reducer.
  22. const { conference, joining } = state['features/base/conference'];
  23. if (app
  24. && app.props.pictureInPictureEnabled
  25. && (conference || joining)) {
  26. const { PictureInPicture } = NativeModules;
  27. const p
  28. = Platform.OS === 'android'
  29. ? PictureInPicture
  30. ? PictureInPicture.enterPictureInPicture()
  31. : Promise.reject(
  32. new Error('Picture-in-Picture not supported'))
  33. : Promise.resolve();
  34. p.then(
  35. () => dispatch({ type: ENTER_PICTURE_IN_PICTURE }),
  36. e => console.warn(`Error entering PiP mode: ${e}`));
  37. }
  38. };
  39. }