You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

functions.js 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // @flow
  2. import { getParticipants } from '../base/participants';
  3. import { VIDEO_PLAYER_PARTICIPANT_NAME } from './constants';
  4. /**
  5. * Validates the entered video url.
  6. *
  7. * It returns a boolean to reflect whether the url matches the youtube regex.
  8. *
  9. * @param {string} url - The entered video link.
  10. * @returns {boolean}
  11. */
  12. export function getYoutubeLink(url: string) {
  13. const p = /^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|(?:m\.)?youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/;// eslint-disable-line max-len
  14. const result = url.match(p);
  15. return result ? result[1] : false;
  16. }
  17. /**
  18. * Checks if the status is one that is actually sharing the video - playing, pause or start.
  19. *
  20. * @param {string} status - The shared video status.
  21. * @returns {boolean}
  22. */
  23. export function isSharingStatus(status: string) {
  24. return [ 'playing', 'pause', 'start' ].includes(status);
  25. }
  26. /**
  27. * Returns true if there is a video being shared in the meeting.
  28. *
  29. * @param {Object | Function} stateful - The Redux state or a function that gets resolved to the Redux state.
  30. * @returns {boolean}
  31. */
  32. export function isVideoPlaying(stateful: Object | Function): boolean {
  33. return Boolean(getParticipants(stateful).find(p => p.isFakeParticipant
  34. && p.name === VIDEO_PLAYER_PARTICIPANT_NAME)
  35. );
  36. }