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.

middleware.js 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // @flow
  2. import { MiddlewareRegistry } from '../redux';
  3. import { PLAY_SOUND } from './actionTypes';
  4. const logger = require('jitsi-meet-logger').getLogger(__filename);
  5. /**
  6. * Implements the entry point of the middleware of the feature base/media.
  7. *
  8. * @param {Store} store - The redux store.
  9. * @returns {Function}
  10. */
  11. MiddlewareRegistry.register(store => next => action => {
  12. switch (action.type) {
  13. case PLAY_SOUND:
  14. _playSound(store, action.soundId);
  15. break;
  16. }
  17. return next(action);
  18. });
  19. /**
  20. * Plays sound from audio element registered in the Redux store.
  21. *
  22. * @param {Store} store - The Redux store instance.
  23. * @param {string} soundId - Audio element identifier.
  24. * @private
  25. * @returns {void}
  26. */
  27. function _playSound({ getState }, soundId) {
  28. const sounds = getState()['features/base/sounds'];
  29. const sound = sounds.get(soundId);
  30. if (sound) {
  31. if (sound.audioElement) {
  32. sound.audioElement.play();
  33. } else {
  34. logger.warn(`PLAY_SOUND: sound not loaded yet for id: ${soundId}`);
  35. }
  36. } else {
  37. logger.warn(`PLAY_SOUND: no sound found for id: ${soundId}`);
  38. }
  39. }