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.

RTCUIHelper.js 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* global $ */
  2. import RTCBrowserType from './RTCBrowserType';
  3. const logger = require('jitsi-meet-logger').getLogger(__filename);
  4. const RTCUIHelper = {
  5. /**
  6. * Returns the name of 'video' element depending on the browser that we're
  7. * currently using.
  8. * @returns {string} 'video' or 'object' string name of WebRTC video element
  9. */
  10. getVideoElementName() {
  11. return RTCBrowserType.isTemasysPluginUsed() ? 'object' : 'video';
  12. },
  13. /**
  14. * Finds video element inside of the given container.
  15. * @param containerElement HTML element node instance which is supposed to
  16. * contain the video element.
  17. * @returns {HTMLElement} video HTML element instance if found inside of the
  18. * container or undefined otherwise.
  19. */
  20. findVideoElement(containerElement) {
  21. const videoElemName = RTCUIHelper.getVideoElementName();
  22. if (!RTCBrowserType.isTemasysPluginUsed()) {
  23. return $(containerElement).find(videoElemName)[0];
  24. }
  25. const matching = $(containerElement).find(
  26. ` ${videoElemName}>param[value="video"]`);
  27. if (matching.length) {
  28. if (matching.length > 1) {
  29. logger.warn(
  30. 'Container with more than one video elements: ',
  31. containerElement);
  32. }
  33. return matching.parent()[0];
  34. }
  35. return undefined;
  36. },
  37. /**
  38. * Returns whether or not the video element fires resize events.
  39. *
  40. * @returns {boolean}
  41. */
  42. isResizeEventSupported() {
  43. return !RTCBrowserType.isTemasysPluginUsed();
  44. },
  45. /**
  46. * Sets 'volume' property of given HTML element displaying RTC audio or
  47. * video stream.
  48. * @param streamElement HTML element to which the RTC stream is attached to.
  49. * @param volume the volume value to be set.
  50. */
  51. setVolume(streamElement, volume) {
  52. if (!RTCBrowserType.isIExplorer()) {
  53. streamElement.volume = volume;
  54. }
  55. },
  56. /**
  57. * Sets 'autoplay' property of given HTML element displaying RTC audio or
  58. * video stream.
  59. * @param streamElement HTML element to which the RTC stream is attached to.
  60. * @param autoPlay 'true' or 'false'
  61. */
  62. setAutoPlay(streamElement, autoPlay) {
  63. if (!RTCBrowserType.isIExplorer()) {
  64. streamElement.autoplay = autoPlay;
  65. }
  66. }
  67. };
  68. export default RTCUIHelper;