EmbedMediaLoader.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. 'use strict';
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. /**
  4. * Licensed Materials - Property of IBM
  5. * IBM Cognos Products: BI Cloud (C) Copyright IBM Corp. 2014, 2019
  6. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. */
  8. define(['./EmbedMedia', 'text!./Mp4Video.html', 'text!./Audio.html'], function (EmbedMedia, Mp4Video, Audio) {
  9. var extractExtension = function extractExtension(url) {
  10. var index = url.lastIndexOf('.');
  11. return index >= 0 ? url.substring(index + 1).toLowerCase() : '';
  12. };
  13. var EmbedMediaLoader = function () {
  14. function EmbedMediaLoader(type) {
  15. _classCallCheck(this, EmbedMediaLoader);
  16. this.type = type;
  17. }
  18. EmbedMediaLoader.prototype.tryToLoad = function tryToLoad(url) {
  19. var extension = extractExtension(url);
  20. var media = null;
  21. switch (extension) {
  22. case 'mp4':
  23. media = new EmbedMedia(url, this.type, Mp4Video);
  24. break;
  25. // TODO: quicktime video is disabled because we remove embed tags for security reason causing this media type not to work
  26. // This needs to be enabled once we do proper validation for the widget content before we save it.
  27. //case 'mov':
  28. // media = new EmbedMedia(url, this.type, QuicktimeVideo);
  29. // break;
  30. case 'mp3':
  31. media = new EmbedMedia(url, this.type, Audio, { type: extension });
  32. break;
  33. case 'aac':
  34. media = new EmbedMedia(url, this.type, Audio, { type: extension });
  35. break;
  36. case 'm4a':
  37. media = new EmbedMedia(url, this.type, Audio, { type: 'mp4' });
  38. break;
  39. default:
  40. break;
  41. }
  42. return media;
  43. };
  44. return EmbedMediaLoader;
  45. }();
  46. return EmbedMediaLoader;
  47. });
  48. //# sourceMappingURL=EmbedMediaLoader.js.map