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.

actions.any.js 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. import { getCurrentConference } from '../base/conference';
  2. import { openDialog } from '../base/dialog/actions';
  3. import { getLocalParticipant } from '../base/participants';
  4. import { SharedVideoDialog } from '../shared-video/components';
  5. import { RESET_SHARED_VIDEO_STATUS, SET_SHARED_VIDEO_STATUS } from './actionTypes';
  6. /**
  7. * Resets the status of the shared video.
  8. *
  9. * @returns {{
  10. * type: SET_SHARED_VIDEO_STATUS,
  11. * }}
  12. */
  13. export function resetSharedVideoStatus() {
  14. return {
  15. type: RESET_SHARED_VIDEO_STATUS
  16. };
  17. }
  18. /**
  19. * Updates the current known status of the shared video.
  20. *
  21. * @param {{
  22. * muted: boolean,
  23. * ownerId: string,
  24. * status: string,
  25. * time: number,
  26. * videoUrl: string
  27. * }} options - The options.
  28. *
  29. * @returns {{
  30. * type: SET_SHARED_VIDEO_STATUS,
  31. * muted: boolean,
  32. * ownerId: string,
  33. * status: string,
  34. * time: number,
  35. * videoUrl: string,
  36. * }}
  37. */
  38. export function setSharedVideoStatus({ videoUrl, status, time, ownerId, muted }) {
  39. return {
  40. type: SET_SHARED_VIDEO_STATUS,
  41. ownerId,
  42. status,
  43. time,
  44. videoUrl,
  45. muted
  46. };
  47. }
  48. /**
  49. * Displays the dialog for entering the video link.
  50. *
  51. * @param {Function} onPostSubmit - The function to be invoked when a valid link is entered.
  52. * @returns {Function}
  53. */
  54. export function showSharedVideoDialog(onPostSubmit) {
  55. return openDialog(SharedVideoDialog, { onPostSubmit });
  56. }
  57. /**
  58. *
  59. * Stops playing a shared video.
  60. *
  61. * @returns {Function}
  62. */
  63. export function stopSharedVideo() {
  64. return (dispatch, getState) => {
  65. const state = getState();
  66. const { ownerId } = state['features/shared-video'];
  67. const localParticipant = getLocalParticipant(state);
  68. if (ownerId === localParticipant.id) {
  69. dispatch(resetSharedVideoStatus());
  70. }
  71. };
  72. }
  73. /**
  74. *
  75. * Plays a shared video.
  76. *
  77. * @param {string} videoUrl - The video url to be played.
  78. *
  79. * @returns {Function}
  80. */
  81. export function playSharedVideo(videoUrl) {
  82. return (dispatch, getState) => {
  83. const conference = getCurrentConference(getState());
  84. if (conference) {
  85. const localParticipant = getLocalParticipant(getState());
  86. dispatch(setSharedVideoStatus({
  87. videoUrl,
  88. status: 'start',
  89. time: 0,
  90. ownerId: localParticipant.id
  91. }));
  92. }
  93. };
  94. }
  95. /**
  96. *
  97. * Stops playing a shared video.
  98. *
  99. * @returns {Function}
  100. */
  101. export function toggleSharedVideo() {
  102. return (dispatch, getState) => {
  103. const state = getState();
  104. const { status } = state['features/shared-video'];
  105. if ([ 'playing', 'start', 'pause' ].includes(status)) {
  106. dispatch(stopSharedVideo());
  107. } else {
  108. dispatch(showSharedVideoDialog(id => dispatch(playSharedVideo(id))));
  109. }
  110. };
  111. }