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.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* global $ */
  2. const logger = require('jitsi-meet-logger').getLogger(__filename);
  3. const RTCBrowserType = require('./RTCBrowserType');
  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. * Sets 'volume' property of given HTML element displaying RTC audio or
  39. * video stream.
  40. * @param streamElement HTML element to which the RTC stream is attached to.
  41. * @param volume the volume value to be set.
  42. */
  43. setVolume(streamElement, volume) {
  44. if (!RTCBrowserType.isIExplorer()) {
  45. streamElement.volume = volume;
  46. }
  47. },
  48. /**
  49. * Sets 'autoplay' property of given HTML element displaying RTC audio or
  50. * video stream.
  51. * @param streamElement HTML element to which the RTC stream is attached to.
  52. * @param autoPlay 'true' or 'false'
  53. */
  54. setAutoPlay(streamElement, autoPlay) {
  55. if (!RTCBrowserType.isIExplorer()) {
  56. streamElement.autoplay = autoPlay;
  57. }
  58. }
  59. };
  60. module.exports = RTCUIHelper;