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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* global $, __filename */
  2. var logger = require("jitsi-meet-logger").getLogger(__filename);
  3. var RTCBrowserType = require("./RTCBrowserType");
  4. var RTC = require('./RTC');
  5. var RTCUIHelper = {
  6. /**
  7. * Returns the name of 'video' element depending on the browser that we're
  8. * currently using.
  9. * @returns {string} 'video' or 'object' string name of WebRTC video element
  10. */
  11. getVideoElementName: function () {
  12. return RTCBrowserType.isTemasysPluginUsed() ? 'object' : 'video';
  13. },
  14. /**
  15. * Finds video element inside of the given container.
  16. * @param containerElement HTML element node instance which is supposed to
  17. * contain the video element.
  18. * @returns {HTMLElement} video HTML element instance if found inside of the
  19. * container or undefined otherwise.
  20. */
  21. findVideoElement: function (containerElement) {
  22. var videoElemName = RTCUIHelper.getVideoElementName();
  23. if (!RTCBrowserType.isTemasysPluginUsed()) {
  24. return $(containerElement).find(videoElemName)[0];
  25. } else {
  26. var matching = $(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. }
  37. return undefined;
  38. },
  39. /**
  40. * Sets 'volume' property of given HTML element displaying RTC audio or
  41. * video stream.
  42. * @param streamElement HTML element to which the RTC stream is attached to.
  43. * @param volume the volume value to be set.
  44. */
  45. setVolume: function (streamElement, volume) {
  46. if (!RTCBrowserType.isIExplorer()) {
  47. streamElement.volume = volume;
  48. }
  49. },
  50. /**
  51. * Sets 'autoplay' property of given HTML element displaying RTC audio or
  52. * video stream.
  53. * @param streamElement HTML element to which the RTC stream is attached to.
  54. * @param autoPlay 'true' or 'false'
  55. */
  56. setAutoPlay: function (streamElement, autoPlay) {
  57. if (!RTCBrowserType.isIExplorer()) {
  58. streamElement.autoplay = true;
  59. }
  60. }
  61. };
  62. module.exports = RTCUIHelper;