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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* global $ */
  2. import browser from '../browser';
  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 browser.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 (!browser.isTemasysPluginUsed()) {
  23. return $(containerElement).find(videoElemName)[0];
  24. }
  25. const matching
  26. = $(containerElement).find(
  27. ` ${videoElemName}>param[value="video"]`);
  28. if (matching.length) {
  29. if (matching.length > 1) {
  30. logger.warn(
  31. 'Container with more than one video elements: ',
  32. containerElement);
  33. }
  34. return matching.parent()[0];
  35. }
  36. return undefined;
  37. },
  38. /**
  39. * Returns whether or not the video element fires resize events.
  40. *
  41. * @returns {boolean}
  42. */
  43. isResizeEventSupported() {
  44. return !browser.isTemasysPluginUsed();
  45. },
  46. /**
  47. * Sets 'volume' property of given HTML element displaying RTC audio or
  48. * video stream.
  49. * @param streamElement HTML element to which the RTC stream is attached to.
  50. * @param volume the volume value to be set.
  51. */
  52. setVolume(streamElement, volume) {
  53. if (!browser.isIExplorer()) {
  54. streamElement.volume = volume;
  55. }
  56. },
  57. /**
  58. * Sets 'autoplay' property of given HTML element displaying RTC audio or
  59. * video stream.
  60. * @param streamElement HTML element to which the RTC stream is attached to.
  61. * @param autoPlay 'true' or 'false'
  62. */
  63. setAutoPlay(streamElement, autoPlay) {
  64. if (!browser.isIExplorer()) {
  65. streamElement.autoplay = autoPlay;
  66. }
  67. }
  68. };
  69. export default RTCUIHelper;