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.

LargeVideo.js 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. /* global $, APP, Strophe, interfaceConfig */
  2. /* jshint -W101 */
  3. var Avatar = require("../avatar/Avatar");
  4. var RTCBrowserType = require("../../RTC/RTCBrowserType");
  5. var UIUtil = require("../util/UIUtil");
  6. var UIEvents = require("../../../service/UI/UIEvents");
  7. var xmpp = require("../../xmpp/xmpp");
  8. var ToolbarToggler = require("../toolbars/ToolbarToggler");
  9. // FIXME: With Temasys we have to re-select everytime
  10. //var video = $('#largeVideo');
  11. var currentVideoWidth = null;
  12. var currentVideoHeight = null;
  13. // By default we use camera
  14. var getVideoSize = getCameraVideoSize;
  15. var getVideoPosition = getCameraVideoPosition;
  16. /**
  17. * The small video instance that is displayed in the large video
  18. * @type {SmallVideo}
  19. */
  20. var currentSmallVideo = null;
  21. /**
  22. * Indicates whether the large video is enabled.
  23. * @type {boolean}
  24. */
  25. var isEnabled = true;
  26. /**
  27. * Current large video state.
  28. * Possible values - video, prezi or etherpad.
  29. * @type {string}
  30. */
  31. var state = "video";
  32. /**
  33. * Returns the html element associated with the passed state of large video
  34. * @param state the state.
  35. * @returns {JQuery|*|jQuery|HTMLElement} the container.
  36. */
  37. function getContainerByState(state)
  38. {
  39. var selector = null;
  40. switch (state)
  41. {
  42. case "video":
  43. selector = "#largeVideoWrapper";
  44. break;
  45. case "etherpad":
  46. selector = "#etherpad>iframe";
  47. break;
  48. case "prezi":
  49. selector = "#presentation>iframe";
  50. break;
  51. }
  52. return (selector !== null)? $(selector) : null;
  53. }
  54. /**
  55. * Sets the size and position of the given video element.
  56. *
  57. * @param video the video element to position
  58. * @param width the desired video width
  59. * @param height the desired video height
  60. * @param horizontalIndent the left and right indent
  61. * @param verticalIndent the top and bottom indent
  62. */
  63. function positionVideo(video,
  64. width,
  65. height,
  66. horizontalIndent,
  67. verticalIndent,
  68. animate) {
  69. if (animate) {
  70. video.animate({
  71. width: width,
  72. height: height,
  73. top: verticalIndent,
  74. bottom: verticalIndent,
  75. left: horizontalIndent,
  76. right: horizontalIndent
  77. },
  78. {
  79. queue: false,
  80. duration: 500
  81. });
  82. } else {
  83. video.width(width);
  84. video.height(height);
  85. video.css({ top: verticalIndent + 'px',
  86. bottom: verticalIndent + 'px',
  87. left: horizontalIndent + 'px',
  88. right: horizontalIndent + 'px'});
  89. }
  90. }
  91. /**
  92. * Returns an array of the video dimensions, so that it keeps it's aspect
  93. * ratio and fits available area with it's larger dimension. This method
  94. * ensures that whole video will be visible and can leave empty areas.
  95. *
  96. * @return an array with 2 elements, the video width and the video height
  97. */
  98. function getDesktopVideoSize(videoWidth,
  99. videoHeight,
  100. videoSpaceWidth,
  101. videoSpaceHeight) {
  102. if (!videoWidth)
  103. videoWidth = currentVideoWidth;
  104. if (!videoHeight)
  105. videoHeight = currentVideoHeight;
  106. var aspectRatio = videoWidth / videoHeight;
  107. var availableWidth = Math.max(videoWidth, videoSpaceWidth);
  108. var availableHeight = Math.max(videoHeight, videoSpaceHeight);
  109. var filmstrip = $("#remoteVideos");
  110. if (!filmstrip.hasClass("hidden"))
  111. videoSpaceHeight -= filmstrip.outerHeight();
  112. if (availableWidth / aspectRatio >= videoSpaceHeight)
  113. {
  114. availableHeight = videoSpaceHeight;
  115. availableWidth = availableHeight * aspectRatio;
  116. }
  117. if (availableHeight * aspectRatio >= videoSpaceWidth)
  118. {
  119. availableWidth = videoSpaceWidth;
  120. availableHeight = availableWidth / aspectRatio;
  121. }
  122. return [availableWidth, availableHeight];
  123. }
  124. /**
  125. * Returns an array of the video horizontal and vertical indents,
  126. * so that if fits its parent.
  127. *
  128. * @return an array with 2 elements, the horizontal indent and the vertical
  129. * indent
  130. */
  131. function getCameraVideoPosition(videoWidth,
  132. videoHeight,
  133. videoSpaceWidth,
  134. videoSpaceHeight) {
  135. // Parent height isn't completely calculated when we position the video in
  136. // full screen mode and this is why we use the screen height in this case.
  137. // Need to think it further at some point and implement it properly.
  138. var isFullScreen = document.fullScreen ||
  139. document.mozFullScreen ||
  140. document.webkitIsFullScreen;
  141. if (isFullScreen)
  142. videoSpaceHeight = window.innerHeight;
  143. var horizontalIndent = (videoSpaceWidth - videoWidth) / 2;
  144. var verticalIndent = (videoSpaceHeight - videoHeight) / 2;
  145. return [horizontalIndent, verticalIndent];
  146. }
  147. /**
  148. * Returns an array of the video horizontal and vertical indents.
  149. * Centers horizontally and top aligns vertically.
  150. *
  151. * @return an array with 2 elements, the horizontal indent and the vertical
  152. * indent
  153. */
  154. function getDesktopVideoPosition(videoWidth,
  155. videoHeight,
  156. videoSpaceWidth,
  157. videoSpaceHeight) {
  158. var horizontalIndent = (videoSpaceWidth - videoWidth) / 2;
  159. var verticalIndent = 0;// Top aligned
  160. return [horizontalIndent, verticalIndent];
  161. }
  162. /**
  163. * Returns an array of the video dimensions. It respects the
  164. * VIDEO_LAYOUT_FIT config, to fit the video to the screen, by hiding some parts
  165. * of it, or to fit it to the height or width.
  166. *
  167. * @param videoWidth the original video width
  168. * @param videoHeight the original video height
  169. * @param videoSpaceWidth the width of the video space
  170. * @param videoSpaceHeight the height of the video space
  171. * @return an array with 2 elements, the video width and the video height
  172. */
  173. function getCameraVideoSize(videoWidth,
  174. videoHeight,
  175. videoSpaceWidth,
  176. videoSpaceHeight) {
  177. if (!videoWidth)
  178. videoWidth = currentVideoWidth;
  179. if (!videoHeight)
  180. videoHeight = currentVideoHeight;
  181. var aspectRatio = videoWidth / videoHeight;
  182. var availableWidth = videoWidth;
  183. var availableHeight = videoHeight;
  184. if (interfaceConfig.VIDEO_LAYOUT_FIT == 'height') {
  185. availableHeight = videoSpaceHeight;
  186. availableWidth = availableHeight*aspectRatio;
  187. }
  188. else if (interfaceConfig.VIDEO_LAYOUT_FIT == 'width') {
  189. availableWidth = videoSpaceWidth;
  190. availableHeight = availableWidth/aspectRatio;
  191. }
  192. else if (interfaceConfig.VIDEO_LAYOUT_FIT == 'both') {
  193. availableWidth = Math.max(videoWidth, videoSpaceWidth);
  194. availableHeight = Math.max(videoHeight, videoSpaceHeight);
  195. if (availableWidth / aspectRatio < videoSpaceHeight) {
  196. availableHeight = videoSpaceHeight;
  197. availableWidth = availableHeight * aspectRatio;
  198. }
  199. if (availableHeight * aspectRatio < videoSpaceWidth) {
  200. availableWidth = videoSpaceWidth;
  201. availableHeight = availableWidth / aspectRatio;
  202. }
  203. }
  204. return [availableWidth, availableHeight];
  205. }
  206. /**
  207. * Updates the src of the active speaker avatar
  208. * @param jid of the current active speaker
  209. */
  210. function updateActiveSpeakerAvatarSrc() {
  211. var avatar = $("#activeSpeakerAvatar")[0];
  212. var jid = currentSmallVideo.peerJid;
  213. var url = Avatar.getActiveSpeakerUrl(jid);
  214. if (avatar.src === url)
  215. return;
  216. if (jid) {
  217. avatar.src = url;
  218. currentSmallVideo.showAvatar();
  219. }
  220. }
  221. /**
  222. * Change the video source of the large video.
  223. * @param isVisible
  224. */
  225. function changeVideo(isVisible) {
  226. if (!currentSmallVideo) {
  227. console.error("Unable to change large video - no 'currentSmallVideo'");
  228. return;
  229. }
  230. updateActiveSpeakerAvatarSrc();
  231. var largeVideoElement = $('#largeVideo')[0];
  232. APP.RTC.setVideoSrc(largeVideoElement, currentSmallVideo.getSrc());
  233. var flipX = currentSmallVideo.flipX;
  234. largeVideoElement.style.transform = flipX ? "scaleX(-1)" : "none";
  235. LargeVideo.updateVideoSizeAndPosition(currentSmallVideo.getVideoType());
  236. // Only if the large video is currently visible.
  237. if (isVisible) {
  238. LargeVideo.VideoLayout.largeVideoUpdated(currentSmallVideo);
  239. $('#largeVideoWrapper').fadeTo(300, 1);
  240. }
  241. }
  242. /**
  243. * Creates the html elements for the large video.
  244. */
  245. function createLargeVideoHTML()
  246. {
  247. var html = '<div id="largeVideoContainer" class="videocontainer">';
  248. html += '<div id="presentation"></div>' +
  249. '<div id="etherpad"></div>' +
  250. '<a target="_new"><div class="watermark leftwatermark"></div></a>' +
  251. '<a target="_new"><div class="watermark rightwatermark"></div></a>' +
  252. '<a class="poweredby" href="http://jitsi.org" target="_new" >' +
  253. '<span data-i18n="poweredby"></span> jitsi.org' +
  254. '</a>'+
  255. '<div id="activeSpeaker">' +
  256. '<img id="activeSpeakerAvatar" src=""/>' +
  257. '<canvas id="activeSpeakerAudioLevel"></canvas>' +
  258. '</div>' +
  259. '<div id="largeVideoWrapper">' +
  260. '<video id="largeVideo" muted="true"' +
  261. 'autoplay oncontextmenu="return false;"></video>' +
  262. '</div id="largeVideoWrapper">' +
  263. '<span id="videoConnectionMessage"></span>';
  264. html += '</div>';
  265. $(html).prependTo("#videospace");
  266. if (interfaceConfig.SHOW_JITSI_WATERMARK) {
  267. var leftWatermarkDiv
  268. = $("#largeVideoContainer div[class='watermark leftwatermark']");
  269. leftWatermarkDiv.css({display: 'block'});
  270. leftWatermarkDiv.parent().get(0).href
  271. = interfaceConfig.JITSI_WATERMARK_LINK;
  272. }
  273. if (interfaceConfig.SHOW_BRAND_WATERMARK) {
  274. var rightWatermarkDiv
  275. = $("#largeVideoContainer div[class='watermark rightwatermark']");
  276. rightWatermarkDiv.css({display: 'block'});
  277. rightWatermarkDiv.parent().get(0).href
  278. = interfaceConfig.BRAND_WATERMARK_LINK;
  279. rightWatermarkDiv.get(0).style.backgroundImage
  280. = "url(images/rightwatermark.png)";
  281. }
  282. if (interfaceConfig.SHOW_POWERED_BY) {
  283. $("#largeVideoContainer>a[class='poweredby']").css({display: 'block'});
  284. }
  285. if (!RTCBrowserType.isIExplorer()) {
  286. $('#largeVideo').volume = 0;
  287. }
  288. }
  289. var LargeVideo = {
  290. init: function (VideoLayout, emitter) {
  291. if(!isEnabled)
  292. return;
  293. createLargeVideoHTML();
  294. this.VideoLayout = VideoLayout;
  295. this.eventEmitter = emitter;
  296. this.eventEmitter.emit(UIEvents.LARGEVIDEO_INIT);
  297. var self = this;
  298. // Listen for large video size updates
  299. var largeVideo = $('#largeVideo')[0];
  300. var onplaying = function (arg1, arg2, arg3) {
  301. // re-select
  302. if (RTCBrowserType.isTemasysPluginUsed())
  303. largeVideo = $('#largeVideo')[0];
  304. currentVideoWidth = largeVideo.videoWidth;
  305. currentVideoHeight = largeVideo.videoHeight;
  306. self.position(currentVideoWidth, currentVideoHeight);
  307. };
  308. largeVideo.onplaying = onplaying;
  309. },
  310. /**
  311. * Indicates if the large video is currently visible.
  312. *
  313. * @return <tt>true</tt> if visible, <tt>false</tt> - otherwise
  314. */
  315. isLargeVideoVisible: function() {
  316. return $('#largeVideoWrapper').is(':visible');
  317. },
  318. /**
  319. * Returns <tt>true</tt> if the user is currently displayed on large video.
  320. */
  321. isCurrentlyOnLarge: function (resourceJid) {
  322. return currentSmallVideo && resourceJid &&
  323. currentSmallVideo.getResourceJid() === resourceJid;
  324. },
  325. /**
  326. * Updates the large video with the given new video source.
  327. */
  328. updateLargeVideo: function (resourceJid, forceUpdate) {
  329. if(!isEnabled)
  330. return;
  331. var newSmallVideo = this.VideoLayout.getSmallVideo(resourceJid);
  332. console.info('hover in ' + resourceJid + ', video: ', newSmallVideo);
  333. if (!newSmallVideo) {
  334. console.error("Small video not found for: " + resourceJid);
  335. return;
  336. }
  337. if (!LargeVideo.isCurrentlyOnLarge(resourceJid) || forceUpdate) {
  338. $('#activeSpeaker').css('visibility', 'hidden');
  339. var oldSmallVideo = null;
  340. if (currentSmallVideo) {
  341. oldSmallVideo = currentSmallVideo;
  342. }
  343. currentSmallVideo = newSmallVideo;
  344. var oldJid = null;
  345. if (oldSmallVideo)
  346. oldJid = oldSmallVideo.peerJid;
  347. if (oldJid !== resourceJid) {
  348. // we want the notification to trigger even if userJid is undefined,
  349. // or null.
  350. this.eventEmitter.emit(UIEvents.SELECTED_ENDPOINT, resourceJid);
  351. }
  352. // We are doing fadeOut/fadeIn animations on parent div which wraps
  353. // largeVideo, because when Temasys plugin is in use it replaces
  354. // <video> elements with plugin <object> tag. In Safari jQuery is
  355. // unable to store values on this plugin object which breaks all
  356. // animation effects performed on it directly.
  357. //
  358. // If for any reason large video was hidden before calling fadeOut
  359. // changeVideo will never be called, so we call show() in chain just
  360. // to be sure
  361. $('#largeVideoWrapper').show().fadeTo(300, 0,
  362. changeVideo.bind($('#largeVideo'), this.isLargeVideoVisible()));
  363. } else {
  364. if (currentSmallVideo) {
  365. currentSmallVideo.showAvatar();
  366. }
  367. }
  368. },
  369. /**
  370. * Shows/hides the large video.
  371. */
  372. setLargeVideoVisible: function(isVisible) {
  373. if(!isEnabled)
  374. return;
  375. if (isVisible) {
  376. $('#largeVideoWrapper').css({visibility: 'visible'});
  377. $('.watermark').css({visibility: 'visible'});
  378. if(currentSmallVideo)
  379. currentSmallVideo.enableDominantSpeaker(true);
  380. }
  381. else {
  382. $('#largeVideoWrapper').css({visibility: 'hidden'});
  383. $('#activeSpeaker').css('visibility', 'hidden');
  384. $('.watermark').css({visibility: 'hidden'});
  385. if(currentSmallVideo)
  386. currentSmallVideo.enableDominantSpeaker(false);
  387. }
  388. },
  389. onVideoTypeChanged: function (resourceJid, newVideoType) {
  390. if (!isEnabled)
  391. return;
  392. if (LargeVideo.isCurrentlyOnLarge(resourceJid))
  393. {
  394. LargeVideo.updateVideoSizeAndPosition(newVideoType);
  395. this.position(null, null, null, null, true);
  396. }
  397. },
  398. /**
  399. * Positions the large video.
  400. *
  401. * @param videoWidth the stream video width
  402. * @param videoHeight the stream video height
  403. */
  404. position: function (videoWidth, videoHeight,
  405. videoSpaceWidth, videoSpaceHeight, animate) {
  406. if(!isEnabled)
  407. return;
  408. if(!videoSpaceWidth)
  409. videoSpaceWidth = $('#videospace').width();
  410. if(!videoSpaceHeight)
  411. videoSpaceHeight = window.innerHeight;
  412. var videoSize = getVideoSize(videoWidth,
  413. videoHeight,
  414. videoSpaceWidth,
  415. videoSpaceHeight);
  416. var largeVideoWidth = videoSize[0];
  417. var largeVideoHeight = videoSize[1];
  418. var videoPosition = getVideoPosition(largeVideoWidth,
  419. largeVideoHeight,
  420. videoSpaceWidth,
  421. videoSpaceHeight);
  422. var horizontalIndent = videoPosition[0];
  423. var verticalIndent = videoPosition[1];
  424. positionVideo($('#largeVideoWrapper'),
  425. largeVideoWidth,
  426. largeVideoHeight,
  427. horizontalIndent, verticalIndent, animate);
  428. },
  429. /**
  430. * Resizes the large html elements.
  431. *
  432. * @param animate boolean property that indicates whether the resize should
  433. * be animated or not.
  434. * @param isSideBarVisible boolean property that indicates whether the chat
  435. * area is displayed or not.
  436. * If that parameter is null the method will check the chat panel
  437. * visibility.
  438. * @param completeFunction a function to be called when the video space is
  439. * resized
  440. * @returns {*[]} array with the current width and height values of the
  441. * largeVideo html element.
  442. */
  443. resize: function (animate, isSideBarVisible, completeFunction) {
  444. if(!isEnabled)
  445. return;
  446. var availableHeight = window.innerHeight;
  447. var availableWidth = UIUtil.getAvailableVideoWidth(isSideBarVisible);
  448. if (availableWidth < 0 || availableHeight < 0) return;
  449. var avatarSize = interfaceConfig.ACTIVE_SPEAKER_AVATAR_SIZE;
  450. var top = availableHeight / 2 - avatarSize / 4 * 3;
  451. $('#activeSpeaker').css('top', top);
  452. this.VideoLayout
  453. .resizeVideoSpace(animate, isSideBarVisible, completeFunction);
  454. if(animate) {
  455. $('#largeVideoContainer').animate({
  456. width: availableWidth,
  457. height: availableHeight
  458. },
  459. {
  460. queue: false,
  461. duration: 500
  462. });
  463. } else {
  464. $('#largeVideoContainer').width(availableWidth);
  465. $('#largeVideoContainer').height(availableHeight);
  466. }
  467. return [availableWidth, availableHeight];
  468. },
  469. /**
  470. * Resizes the large video.
  471. *
  472. * @param isSideBarVisible indicating if the side bar is visible
  473. * @param completeFunction the callback function to be executed after the
  474. * resize
  475. */
  476. resizeVideoAreaAnimated: function (isSideBarVisible, completeFunction) {
  477. if(!isEnabled)
  478. return;
  479. var size = this.resize(true, isSideBarVisible, completeFunction);
  480. this.position(null, null, size[0], size[1], true);
  481. },
  482. /**
  483. * Updates the video size and position.
  484. *
  485. * @param videoType the video type indicating if the stream is of type
  486. * desktop or web cam
  487. */
  488. updateVideoSizeAndPosition: function (videoType) {
  489. if (!videoType)
  490. videoType = currentSmallVideo.getVideoType();
  491. var isDesktop = videoType === 'screen';
  492. // Change the way we'll be measuring and positioning large video
  493. getVideoSize = isDesktop ? getDesktopVideoSize : getCameraVideoSize;
  494. getVideoPosition = isDesktop ? getDesktopVideoPosition :
  495. getCameraVideoPosition;
  496. },
  497. getResourceJid: function () {
  498. return currentSmallVideo ? currentSmallVideo.getResourceJid() : null;
  499. },
  500. updateAvatar: function (resourceJid) {
  501. if(!isEnabled)
  502. return;
  503. if (resourceJid === this.getResourceJid()) {
  504. updateActiveSpeakerAvatarSrc();
  505. }
  506. },
  507. showAvatar: function (resourceJid, show) {
  508. if (!isEnabled)
  509. return;
  510. if (this.getResourceJid() === resourceJid && state === "video") {
  511. $("#largeVideoWrapper")
  512. .css("visibility", show ? "hidden" : "visible");
  513. $('#activeSpeaker').css("visibility", show ? "visible" : "hidden");
  514. return true;
  515. }
  516. return false;
  517. },
  518. /**
  519. * Disables the large video
  520. */
  521. disable: function () {
  522. isEnabled = false;
  523. },
  524. /**
  525. * Enables the large video
  526. */
  527. enable: function () {
  528. isEnabled = true;
  529. },
  530. /**
  531. * Returns true if the video is enabled.
  532. */
  533. isEnabled: function () {
  534. return isEnabled;
  535. },
  536. /**
  537. * Creates the iframe used by the etherpad
  538. * @param src the value for src attribute
  539. * @param onloadHandler handler executed when the iframe loads it content
  540. * @returns {HTMLElement} the iframe
  541. */
  542. createEtherpadIframe: function (src, onloadHandler) {
  543. if(!isEnabled)
  544. return;
  545. var etherpadIFrame = document.createElement('iframe');
  546. etherpadIFrame.src = src;
  547. etherpadIFrame.frameBorder = 0;
  548. etherpadIFrame.scrolling = "no";
  549. etherpadIFrame.width = $('#largeVideoContainer').width() || 640;
  550. etherpadIFrame.height = $('#largeVideoContainer').height() || 480;
  551. etherpadIFrame.setAttribute('style', 'visibility: hidden;');
  552. document.getElementById('etherpad').appendChild(etherpadIFrame);
  553. etherpadIFrame.onload = onloadHandler;
  554. return etherpadIFrame;
  555. },
  556. /**
  557. * Changes the state of the large video.
  558. * Possible values - video, prezi, etherpad.
  559. * @param newState - the new state
  560. */
  561. setState: function (newState) {
  562. if(state === newState)
  563. return;
  564. var currentContainer = getContainerByState(state);
  565. if(!currentContainer)
  566. return;
  567. var self = this;
  568. var oldState = state;
  569. switch (newState)
  570. {
  571. case "etherpad":
  572. $('#activeSpeaker').css('visibility', 'hidden');
  573. currentContainer.fadeOut(300, function () {
  574. if (oldState === "prezi") {
  575. currentContainer.css({opacity: '0'});
  576. $('#reloadPresentation').css({display: 'none'});
  577. }
  578. else {
  579. self.setLargeVideoVisible(false);
  580. }
  581. });
  582. $('#etherpad>iframe').fadeIn(300, function () {
  583. document.body.style.background = '#eeeeee';
  584. $('#etherpad>iframe').css({visibility: 'visible'});
  585. $('#etherpad').css({zIndex: 2});
  586. });
  587. break;
  588. case "prezi":
  589. var prezi = $('#presentation>iframe');
  590. currentContainer.fadeOut(300, function() {
  591. document.body.style.background = 'black';
  592. });
  593. prezi.fadeIn(300, function() {
  594. prezi.css({opacity:'1'});
  595. ToolbarToggler.dockToolbar(true);//fix that
  596. self.setLargeVideoVisible(false);
  597. $('#etherpad>iframe').css({visibility: 'hidden'});
  598. $('#etherpad').css({zIndex: 0});
  599. });
  600. $('#activeSpeaker').css('visibility', 'hidden');
  601. break;
  602. case "video":
  603. currentContainer.fadeOut(300, function () {
  604. $('#presentation>iframe').css({opacity:'0'});
  605. $('#reloadPresentation').css({display:'none'});
  606. $('#etherpad>iframe').css({visibility: 'hidden'});
  607. $('#etherpad').css({zIndex: 0});
  608. document.body.style.background = 'black';
  609. ToolbarToggler.dockToolbar(false);//fix that
  610. });
  611. $('#largeVideoWrapper').fadeIn(300, function () {
  612. self.setLargeVideoVisible(true);
  613. });
  614. break;
  615. }
  616. state = newState;
  617. },
  618. /**
  619. * Returns the current state of the large video.
  620. * @returns {string} the current state - video, prezi or etherpad.
  621. */
  622. getState: function () {
  623. return state;
  624. },
  625. /**
  626. * Sets hover handlers for the large video container div.
  627. *
  628. * @param inHandler
  629. * @param outHandler
  630. */
  631. setHover: function(inHandler, outHandler)
  632. {
  633. $('#largeVideoContainer').hover(inHandler, outHandler);
  634. },
  635. /**
  636. * Enables/disables the filter indicating a video problem to the user.
  637. *
  638. * @param enable <tt>true</tt> to enable, <tt>false</tt> to disable
  639. */
  640. enableVideoProblemFilter: function (enable) {
  641. $("#largeVideo").toggleClass("videoProblemFilter", enable);
  642. }
  643. };
  644. module.exports = LargeVideo;