EmbedMedia.js 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5. /**
  6. * Licensed Materials - Property of IBM
  7. * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2014, 2019
  8. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. */
  10. define(['underscore', 'doT', './MediaBase', 'text!./Media.html'], function (_, dot, MediaBase, Template) {
  11. var template = dot.template(Template);
  12. var EmbedMedia = function (_MediaBase) {
  13. _inherits(EmbedMedia, _MediaBase);
  14. function EmbedMedia(url, id, videoTemplate, extraTemplateArguments) {
  15. _classCallCheck(this, EmbedMedia);
  16. var _this = _possibleConstructorReturn(this, _MediaBase.apply(this, arguments));
  17. _this.videoTemplate = dot.template(videoTemplate);
  18. _this.extraTemplateArguments = extraTemplateArguments || {};
  19. return _this;
  20. }
  21. EmbedMedia.prototype.getDimensions = function getDimensions() {
  22. return Promise.resolve(null);
  23. };
  24. EmbedMedia.prototype.getMarkup = function getMarkup(params) {
  25. _.extend(params, this.extraTemplateArguments, {
  26. url: this.url
  27. });
  28. return template({
  29. mediaMarkup: this.videoTemplate(params)
  30. });
  31. };
  32. EmbedMedia.prototype.markupLoaded = function markupLoaded($el /*, mode*/) {
  33. var _MediaBase$prototype$;
  34. this.$el = $el;
  35. (_MediaBase$prototype$ = _MediaBase.prototype.markupLoaded).call.apply(_MediaBase$prototype$, [this].concat(Array.prototype.slice.call(arguments)));
  36. };
  37. EmbedMedia.prototype.showAuthoringMode = function showAuthoringMode() {
  38. var mediaTag = this.$el.find('iframe.youtubePlayer, video, audio');
  39. if (mediaTag[0]) {
  40. switch (mediaTag[0].tagName) {
  41. case 'IFRAME':
  42. {
  43. var iFrame = mediaTag[0].contentWindow;
  44. iFrame.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*');
  45. }
  46. break;
  47. case 'VIDEO':
  48. case 'AUDIO':
  49. // HTML5 Audio/Video APIs
  50. mediaTag[0].pause();
  51. break;
  52. default:
  53. break;
  54. }
  55. }
  56. var $container = this.$el.find('.mediaContainer');
  57. $container.removeClass('consume');
  58. $container.addClass('authoring');
  59. };
  60. EmbedMedia.prototype.showConsumeMode = function showConsumeMode() {
  61. var $container = this.$el.find('.mediaContainer');
  62. $container.removeClass('authoring');
  63. $container.addClass('consume');
  64. };
  65. return EmbedMedia;
  66. }(MediaBase);
  67. return EmbedMedia;
  68. });
  69. //# sourceMappingURL=EmbedMedia.js.map