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 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // @flow
  2. import { MEDIA_TYPE } from '../media';
  3. import { getTrackByMediaTypeAndParticipant } from '../tracks';
  4. /**
  5. * Indicates whether the test mode is enabled. When it's enabled
  6. * {@link TestHint} and other components from the testing package will be
  7. * rendered in various places across the app to help with automatic testing.
  8. *
  9. * @param {Object} state - The redux store state.
  10. * @returns {boolean}
  11. */
  12. export function isTestModeEnabled(state: Object): boolean {
  13. const testingConfig = state['features/base/config'].testing;
  14. return Boolean(testingConfig && testingConfig.testMode);
  15. }
  16. /**
  17. * Returns the video type of the remote participant's video.
  18. *
  19. * @param {Store} store - The redux store.
  20. * @param {string} id - The participant ID for the remote video.
  21. * @returns {MEDIA_TYPE}
  22. */
  23. export function getRemoteVideoType({ getState }: Object, id: String): boolean {
  24. return getTrackByMediaTypeAndParticipant(getState()['features/base/tracks'], MEDIA_TYPE.VIDEO, id)?.videoType;
  25. }
  26. /**
  27. * Returns whether the last media event received for large video indicates that the video is playing, if not muted.
  28. *
  29. * @param {Store} store - The redux store.
  30. * @returns {boolean}
  31. */
  32. export function isLargeVideoReceived({ getState }: Object): boolean {
  33. const largeVideoParticipantId = getState()['features/large-video'].participantId;
  34. const videoTrack = getTrackByMediaTypeAndParticipant(
  35. getState()['features/base/tracks'], MEDIA_TYPE.VIDEO, largeVideoParticipantId);
  36. const lastMediaEvent = getState()['features/large-video'].lastMediaEvent;
  37. return videoTrack && !videoTrack.muted && (lastMediaEvent === 'playing' || lastMediaEvent === 'canplaythrough');
  38. }
  39. /**
  40. * Returns whether the last media event received for a remote video indicates that the video is playing, if not muted.
  41. *
  42. * @param {Store} store - The redux store.
  43. * @param {string} id - The participant ID for the remote video.
  44. * @returns {boolean}
  45. */
  46. export function isRemoteVideoReceived({ getState }: Object, id: String): boolean {
  47. const videoTrack = getTrackByMediaTypeAndParticipant(getState()['features/base/tracks'], MEDIA_TYPE.VIDEO, id);
  48. const lastMediaEvent = videoTrack?.lastMediaEvent;
  49. return !videoTrack.muted && (lastMediaEvent === 'playing' || lastMediaEvent === 'canplaythrough');
  50. }