選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

RTCUIHelper.js 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. * Sets 'volume' property of given HTML element displaying RTC audio or
  46. * video stream.
  47. * @param streamElement HTML element to which the RTC stream is attached to.
  48. * @param volume the volume value to be set.
  49. */
  50. setVolume: function (streamElement, volume) {
  51. if (!RTCBrowserType.isIExplorer()) {
  52. streamElement.volume = volume;
  53. }
  54. },
  55. /**
  56. * Sets 'autoplay' property of given HTML element displaying RTC audio or
  57. * video stream.
  58. * @param streamElement HTML element to which the RTC stream is attached to.
  59. * @param autoPlay 'true' or 'false'
  60. */
  61. setAutoPlay: function (streamElement, autoPlay) {
  62. if (!RTCBrowserType.isIExplorer()) {
  63. streamElement.autoplay = true;
  64. }
  65. }
  66. };
  67. module.exports = RTCUIHelper;