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 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* global $ */
  2. var RTCBrowserType = require("./RTCBrowserType");
  3. var RTCUIHelper = {
  4. /**
  5. * Returns the name of 'video' element depending on the browser that we're
  6. * currently using.
  7. * @returns {string} 'video' or 'object' string name of WebRTC video element
  8. */
  9. getVideoElementName: function () {
  10. return RTCBrowserType.isTemasysPluginUsed() ? 'object' : 'video';
  11. },
  12. /**
  13. * Finds video element inside of the given container.
  14. * @param containerElement HTML element node instance which is supposed to
  15. * contain the video element.
  16. * @returns {HTMLElement} video HTML element instance if found inside of the
  17. * container or undefined otherwise.
  18. */
  19. findVideoElement: function (containerElement) {
  20. var videoElemName = RTCUIHelper.getVideoElementName();
  21. if (!RTCBrowserType.isTemasysPluginUsed()) {
  22. return $(containerElement).find(videoElemName)[0];
  23. } else {
  24. var matching = $(containerElement).find(
  25. ' ' + videoElemName + '>param[value="video"]');
  26. if (matching.length < 2) {
  27. return matching.parent()[0];
  28. } else {
  29. // there are 2 video objects from FF
  30. // object with id which ends with '_default'
  31. // (like 'remoteVideo_default')
  32. // doesn't contain video, so we ignore it
  33. for (var i = 0; i < matching.length; i += 1) {
  34. var el = matching[i].parentNode;
  35. // check id suffix
  36. if (el.id.substr(-8) !== '_default') {
  37. return el;
  38. }
  39. }
  40. }
  41. }
  42. return undefined;
  43. }
  44. };
  45. module.exports = RTCUIHelper;