Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

actions.js 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // @flow
  2. import { NativeModules } from 'react-native';
  3. import { getAppProp } from '../../base/app';
  4. import { Platform } from '../../base/react';
  5. import { ENTER_PICTURE_IN_PICTURE } from './actionTypes';
  6. const logger = require('jitsi-meet-logger').getLogger(__filename);
  7. /**
  8. * Enters (or rather initiates entering) picture-in-picture.
  9. * Helper function to enter PiP mode. This is triggered by user request
  10. * (either pressing the button in the toolbox or the home button on Android)
  11. * ans this triggers the PiP mode, iff it's available and we are in a
  12. * conference.
  13. *
  14. * @public
  15. * @returns {Function}
  16. */
  17. export function enterPictureInPicture() {
  18. return (dispatch: Dispatch, getState: Function) => {
  19. // XXX At the time of this writing this action can only be dispatched by
  20. // the button which is on the conference view, which means that it's
  21. // fine to enter PiP mode.
  22. if (getAppProp(getState, 'pictureInPictureEnabled')) {
  23. const { PictureInPicture } = NativeModules;
  24. const p
  25. = Platform.OS === 'android'
  26. ? PictureInPicture
  27. ? PictureInPicture.enterPictureInPicture()
  28. : Promise.reject(
  29. new Error('Picture-in-Picture not supported'))
  30. : Promise.resolve();
  31. p.then(
  32. () => dispatch({ type: ENTER_PICTURE_IN_PICTURE }),
  33. e => logger.warn(`Error entering PiP mode: ${e}`));
  34. }
  35. };
  36. }