@xibosignage/xibo-layout-renderer 1.0.23 → 1.0.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -834,31 +834,37 @@ var XiboLayoutRenderer = (function (exports) {
834
834
  case 0:
835
835
  _context2.next = 2;
836
836
  return Promise.all(list.map( /*#__PURE__*/function () {
837
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(item) {
838
- var inputOverlay, overlayLayout, $overlay;
837
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(item, index) {
838
+ var _item$index;
839
+ var inputOverlay, overlayLayout, $overlay, _overlayLayout$zIndex;
839
840
  return _regeneratorRuntime().wrap(function _callee$(_context) {
840
841
  while (1) switch (_context.prev = _context.next) {
841
842
  case 0:
842
843
  inputOverlay = {};
843
844
  inputOverlay = _objectSpread2(_objectSpread2({}, inputOverlay), item);
844
- inputOverlay.index = item.index;
845
+ inputOverlay.index = (_item$index = item.index) !== null && _item$index !== void 0 ? _item$index : index;
845
846
  _context.next = 5;
846
847
  return _this.parent.prepareLayoutXlf(_objectSpread2(_objectSpread2({}, initialLayout), inputOverlay));
847
848
  case 5:
848
849
  overlayLayout = _context.sent;
850
+ console.debug('<> XLR.debug OverlayLayoutManager::parseOverlays prepared overlay layout', {
851
+ overlayLayout: overlayLayout,
852
+ inputOverlay: inputOverlay
853
+ });
849
854
  // Hide all overlays first
850
855
  $overlay = document.querySelector("#".concat(overlayLayout.containerName, "[data-sequence=\"").concat(overlayLayout.index, "\"]"));
851
856
  if ($overlay !== null) {
852
- $overlay.style.setProperty('display', 'none');
857
+ $overlay.style.setProperty('visibility', 'hidden');
858
+ $overlay.style.setProperty('z-index', "".concat((_overlayLayout$zIndex = overlayLayout.zIndex) !== null && _overlayLayout$zIndex !== void 0 ? _overlayLayout$zIndex : -999));
853
859
  }
854
860
  return _context.abrupt("return", overlayLayout);
855
- case 9:
861
+ case 10:
856
862
  case "end":
857
863
  return _context.stop();
858
864
  }
859
865
  }, _callee);
860
866
  }));
861
- return function (_x2) {
867
+ return function (_x2, _x3) {
862
868
  return _ref.apply(this, arguments);
863
869
  };
864
870
  }()));
@@ -987,7 +993,7 @@ var XiboLayoutRenderer = (function (exports) {
987
993
  }
988
994
  }, _callee3, this, [[12, 21, 24, 27]]);
989
995
  }));
990
- function prepareOverlayLayouts(_x3, _x4) {
996
+ function prepareOverlayLayouts(_x4, _x5) {
991
997
  return _prepareOverlayLayouts.apply(this, arguments);
992
998
  }
993
999
  return prepareOverlayLayouts;
@@ -998,7 +1004,8 @@ var XiboLayoutRenderer = (function (exports) {
998
1004
  var _this$parent$currentL;
999
1005
  if (this.overlays.length === 0) return;
1000
1006
  if (this.parent && (_this$parent$currentL = this.parent.currentLayout) !== null && _this$parent$currentL !== void 0 && _this$parent$currentL.isInterrupt()) {
1001
- this.container.style.setProperty('display', 'none');
1007
+ this.container.style.setProperty('visibility', 'hidden');
1008
+ this.container.style.setProperty('z-index', '-999');
1002
1009
  return;
1003
1010
  }
1004
1011
  this.overlays.forEach(function (overlay) {
@@ -1016,21 +1023,25 @@ var XiboLayoutRenderer = (function (exports) {
1016
1023
  while (1) switch (_context5.prev = _context5.next) {
1017
1024
  case 0:
1018
1025
  overlayHtml = document.querySelector("#".concat(overlay.containerName, "[data-sequence=\"").concat(overlay.index, "\"]"));
1026
+ console.debug('<> XLR.debug OverlayLayoutManager::stopOverlays', {
1027
+ overlay: overlay,
1028
+ overlayHtml: overlayHtml
1029
+ });
1019
1030
  if (!(overlayHtml !== null)) {
1020
- _context5.next = 5;
1031
+ _context5.next = 6;
1021
1032
  break;
1022
1033
  }
1023
- _context5.next = 4;
1034
+ _context5.next = 5;
1024
1035
  return overlay.finishAllRegions();
1025
- case 4:
1026
- overlay.emitter.emit('end', overlay);
1027
1036
  case 5:
1037
+ overlay.emitter.emit('end', overlay);
1038
+ case 6:
1028
1039
  case "end":
1029
1040
  return _context5.stop();
1030
1041
  }
1031
1042
  }, _callee4);
1032
1043
  }));
1033
- return function (_x5) {
1044
+ return function (_x6) {
1034
1045
  return _ref2.apply(this, arguments);
1035
1046
  };
1036
1047
  }());
@@ -72516,6 +72527,269 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
72516
72527
  videojs.registerPlugin('reloadSourceOnError', reloadSourceOnError);
72517
72528
  }
72518
72529
 
72530
+ function composeVideoSource($media, media) {
72531
+ // const videoSrc = await preloadMediaBlob(media.url as string, media.mediaType as MediaTypes);
72532
+ var vidType = videoFileType(getFileExt(media.uri));
72533
+ // Only add one source per type
72534
+ if ($media.querySelectorAll("source[type=\"".concat(vidType, "\"]")).length === 0) {
72535
+ var $videoSource = document.createElement('source');
72536
+ $videoSource.src = media.url;
72537
+ $videoSource.type = vidType;
72538
+ $media.insertBefore($videoSource, $media.lastElementChild);
72539
+ }
72540
+ return $media;
72541
+ }
72542
+ var defaultVjsOpts = {
72543
+ autoplay: false,
72544
+ muted: true,
72545
+ // Start muted to allow autoplay policies
72546
+ preload: 'auto',
72547
+ controls: false
72548
+ };
72549
+ var vjsDefaultOptions = function vjsDefaultOptions(opts) {
72550
+ return _objectSpread2({
72551
+ controls: false,
72552
+ preload: 'auto',
72553
+ autoplay: false,
72554
+ muted: true
72555
+ }, opts);
72556
+ };
72557
+ var reportToPlayerPlatform = [exports.ConsumerPlatform.CHROMEOS, exports.ConsumerPlatform.ELECTRON];
72558
+ function VideoMedia(media, xlr) {
72559
+ var mediaId = getMediaId(media);
72560
+ var videoPlayer = {
72561
+ duration: 0,
72562
+ init: function init() {
72563
+ var _this = this;
72564
+ var triggerTimeUpdate = false; // Used for media.duration === 0
72565
+ videoPlayer.duration = media.duration;
72566
+ var vjsPlayer = videojs(mediaId);
72567
+ if (vjsPlayer) {
72568
+ vjsPlayer.on('loadstart', function () {
72569
+ console.debug("??? XLR.debug >> VideoMedia: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has started loading data . . ."));
72570
+ });
72571
+ vjsPlayer.on('loadedmetadata', function () {
72572
+ if (media.duration === 0) {
72573
+ videoPlayer.duration = vjsPlayer.duration();
72574
+ }
72575
+ console.debug('??? XLR.debug >> VideoMedia: loadedmetadata: Setting video duration to = ' + videoPlayer.duration);
72576
+ });
72577
+ vjsPlayer.on('canplay', function () {
72578
+ console.debug("??? XLR.debug >> VideoMedia: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " can be played . . ."));
72579
+ });
72580
+ vjsPlayer.on('playing', function () {
72581
+ // Update duration
72582
+ if (videoPlayer.duration === 0) {
72583
+ videoPlayer.duration = vjsPlayer.duration();
72584
+ }
72585
+ console.debug('??? XLR.debug >> VideoMedia: playing: Showing Media ' + media.id + ' for ' + videoPlayer.duration + 's of Region ' + media.region.regionId);
72586
+ console.debug("??? XLR.debug >> VideoMedia: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " is now playing . . ."));
72587
+ });
72588
+ // @NOTE: When video is paused due to fail in unmuting the video
72589
+ // and video has media.duration = 0, the video will stay paused and the video cycle won't end
72590
+ // @TODO: Add timer when video is paused due to unmuting fail and duration that is equal to 0
72591
+ // @NOTE: The pause issue when unmuting the video is mainly on a browser level.
72592
+ // Please visit https://developer.chrome.com/blog/autoplay/ for more info.
72593
+ vjsPlayer.ready(function () {
72594
+ // Add guard making sure that video element is present
72595
+ var videoElem = document.querySelector(".media--item.".concat(mediaId));
72596
+ if (!document.body.contains(videoElem)) {
72597
+ media.emitter.emit('cancelled', media);
72598
+ return;
72599
+ }
72600
+ if (vjsPlayer !== undefined) {
72601
+ vjsPlayer.muted(true);
72602
+ // Race promise between a 0.5s play and a 5s skip
72603
+ Promise.race([new Promise(function (resolve, reject) {
72604
+ return setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
72605
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
72606
+ while (1) switch (_context.prev = _context.next) {
72607
+ case 0:
72608
+ console.debug("??? XLR.debug >> VideoMedia: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Trying to force play after 0.1 seconds"));
72609
+ // Try to force play here
72610
+ _context.prev = 1;
72611
+ if (!(vjsPlayer.currentTime() === 0)) {
72612
+ _context.next = 6;
72613
+ break;
72614
+ }
72615
+ // Set video mute/unmute based on setting once playing
72616
+ vjsPlayer.muted(media.muted);
72617
+ _context.next = 6;
72618
+ return vjsPlayer.play();
72619
+ case 6:
72620
+ // Resolve if play works
72621
+ resolve(true);
72622
+ _context.next = 12;
72623
+ break;
72624
+ case 9:
72625
+ _context.prev = 9;
72626
+ _context.t0 = _context["catch"](1);
72627
+ // Reject race if play fails
72628
+ reject('Play failed');
72629
+ case 12:
72630
+ case "end":
72631
+ return _context.stop();
72632
+ }
72633
+ }, _callee, null, [[1, 9]]);
72634
+ })), 100);
72635
+ }), new Promise(function (_, reject) {
72636
+ return setTimeout(function () {
72637
+ return reject('Timeout');
72638
+ }, 5000);
72639
+ })]).then(function () {
72640
+ console.debug("??? XLR.debug >> VideoMedia: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Autoplay started"));
72641
+ })["catch"]( /*#__PURE__*/function () {
72642
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(error) {
72643
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
72644
+ while (1) switch (_context2.prev = _context2.next) {
72645
+ case 0:
72646
+ if (error === 'Timeout') {
72647
+ console.debug("??? XLR.debug >> VideoMedia: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Promise not resolved within 5 seconds. Move to next media"));
72648
+ _this.stop();
72649
+ } else {
72650
+ console.debug("??? XLR.debug >> VideoMedia: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Autoplay error: ").concat(error));
72651
+ if (reportToPlayerPlatform.includes(xlr.config.platform)) {
72652
+ playerReportFault('Media autoplay error', media).then(function () {
72653
+ _this.stop();
72654
+ });
72655
+ }
72656
+ }
72657
+ case 1:
72658
+ case "end":
72659
+ return _context2.stop();
72660
+ }
72661
+ }, _callee2);
72662
+ }));
72663
+ return function (_x) {
72664
+ return _ref2.apply(this, arguments);
72665
+ };
72666
+ }());
72667
+ // Optional: Reset the flag automatically when a new video loads or the source changes
72668
+ vjsPlayer.on('loadstart', function () {
72669
+ triggerTimeUpdate = false;
72670
+ });
72671
+ if (media.duration === 0) {
72672
+ vjsPlayer.on('timeupdate', function () {
72673
+ var preloadBufferTimeMs = 2000;
72674
+ var mediaDuration = vjsPlayer.duration();
72675
+ var currentTime = vjsPlayer.currentTime();
72676
+ var regionHasMultipleMedia = media.region.totalMediaObjects > 1;
72677
+ var remainingTimeMs = 0;
72678
+ if (mediaDuration !== undefined && currentTime !== undefined) {
72679
+ remainingTimeMs = (mediaDuration - currentTime) * 1000;
72680
+ }
72681
+ if (regionHasMultipleMedia && remainingTimeMs === 0 && !triggerTimeUpdate) {
72682
+ // We don't have data yet and we must immediately prepare next media
72683
+ media.region.prepareNextMedia();
72684
+ } else if (regionHasMultipleMedia && remainingTimeMs <= preloadBufferTimeMs && !triggerTimeUpdate) {
72685
+ // Check if remaining time is less than preloadBufferTimeMs and the action hasn't been triggered yet
72686
+ console.log('Less than preloadBufferTimeMs remaining! Do something now.');
72687
+ // Prepare next media in region
72688
+ media.region.prepareNextMedia();
72689
+ triggerTimeUpdate = true; // Set the flag to prevent re-triggering
72690
+ }
72691
+ // Reset the flag if the user seeks back to a point where more than preloadBufferTimeMs remain
72692
+ if (remainingTimeMs > preloadBufferTimeMs) {
72693
+ triggerTimeUpdate = false;
72694
+ }
72695
+ });
72696
+ }
72697
+ }
72698
+ });
72699
+ vjsPlayer.on('error', /*#__PURE__*/function () {
72700
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(err) {
72701
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
72702
+ while (1) switch (_context3.prev = _context3.next) {
72703
+ case 0:
72704
+ console.debug("??? XLR.debug >> VideoMedia: Media Error: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id));
72705
+ if (reportToPlayerPlatform.includes(xlr.config.platform)) {
72706
+ playerReportFault('Video file source not supported', media).then(function () {
72707
+ _this.stop();
72708
+ });
72709
+ } else {
72710
+ // End media after 5 seconds
72711
+ setTimeout(function () {
72712
+ console.debug("??? XLR.debug >> VideoMedia: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has ended . . ."));
72713
+ _this.stop();
72714
+ }, 5000);
72715
+ }
72716
+ case 2:
72717
+ case "end":
72718
+ return _context3.stop();
72719
+ }
72720
+ }, _callee3);
72721
+ }));
72722
+ return function (_x2) {
72723
+ return _ref3.apply(this, arguments);
72724
+ };
72725
+ }());
72726
+ if (media.duration === 0) {
72727
+ vjsPlayer.on('ended', function () {
72728
+ console.debug("??? XLR.debug >> VideoMedia: onended: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has ended playing . . ."));
72729
+ _this.stop();
72730
+ });
72731
+ }
72732
+ }
72733
+ },
72734
+ stop: function stop() {
72735
+ var disposeOnly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
72736
+ var vjsPlayer = media.player;
72737
+ console.debug('??? XLR.debug >> VideoMedia::stop', {
72738
+ vjsPlayer: vjsPlayer,
72739
+ isDisposed: vjsPlayer === null || vjsPlayer === void 0 ? void 0 : vjsPlayer.isDisposed_,
72740
+ el: vjsPlayer === null || vjsPlayer === void 0 ? void 0 : vjsPlayer.el_
72741
+ });
72742
+ // Expire the media and dispose the video
72743
+ if (vjsPlayer !== undefined && !vjsPlayer.isDisposed_) {
72744
+ if (!disposeOnly) {
72745
+ media.emitter.emit('end', media);
72746
+ }
72747
+ vjsPlayer.dispose();
72748
+ // Clear up media player
72749
+ media.player = undefined;
72750
+ } else {
72751
+ media.player = undefined;
72752
+ media.html = null;
72753
+ media.emitter.emit('end', media);
72754
+ }
72755
+ },
72756
+ play: function play() {
72757
+ var _this2 = this;
72758
+ var vjsPlayer = videojs(mediaId);
72759
+ if (vjsPlayer !== undefined) {
72760
+ var _vjsPlayer$play;
72761
+ (_vjsPlayer$play = vjsPlayer.play()) === null || _vjsPlayer$play === void 0 || _vjsPlayer$play["catch"]( /*#__PURE__*/function () {
72762
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(error) {
72763
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
72764
+ while (1) switch (_context4.prev = _context4.next) {
72765
+ case 0:
72766
+ if (error === 'Timeout') {
72767
+ console.debug("??? XLR.debug >> VideoMedia: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Promise not resolved within 5 seconds. Move to next media"));
72768
+ _this2.stop();
72769
+ } else {
72770
+ console.debug("??? XLR.debug >> VideoMedia: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Autoplay error: ").concat(error));
72771
+ if (reportToPlayerPlatform.includes(xlr.config.platform)) {
72772
+ playerReportFault('Media autoplay error', media).then(function () {
72773
+ _this2.stop();
72774
+ });
72775
+ }
72776
+ }
72777
+ case 1:
72778
+ case "end":
72779
+ return _context4.stop();
72780
+ }
72781
+ }, _callee4);
72782
+ }));
72783
+ return function (_x3) {
72784
+ return _ref4.apply(this, arguments);
72785
+ };
72786
+ }());
72787
+ }
72788
+ }
72789
+ };
72790
+ return videoPlayer;
72791
+ }
72792
+
72519
72793
  /*
72520
72794
  * Copyright (C) 2024 Xibo Signage Ltd
72521
72795
  *
@@ -72750,65 +73024,6 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
72750
73024
  return keyframes;
72751
73025
  };
72752
73026
 
72753
- function AudioMedia(media) {
72754
- var audioMediaObject = {
72755
- init: function init() {
72756
- var $audioMedia = document.getElementById(getMediaId(media));
72757
- var $playBtn = null;
72758
- if ($audioMedia) {
72759
- $audioMedia.onloadstart = function () {
72760
- console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has started loading data . . ."));
72761
- };
72762
- $audioMedia.onloadeddata = function () {
72763
- if ($audioMedia.readyState >= 2) {
72764
- console.debug("".concat(capitalizeStr(media.mediaType), " data for media > ").concat(media.id, " has been fully loaded . . ."));
72765
- }
72766
- };
72767
- $audioMedia.oncanplay = function () {
72768
- console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " can be played . . ."));
72769
- };
72770
- $audioMedia.onplaying = function () {
72771
- console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " is now playing . . ."));
72772
- if ($playBtn !== null) {
72773
- $playBtn.remove();
72774
- }
72775
- };
72776
- var audioPlayPromise = $audioMedia.play();
72777
- if (audioPlayPromise !== undefined) {
72778
- audioPlayPromise.then(function () {
72779
- console.debug('autoplay started . . .');
72780
- // Autoplay restarted
72781
- })["catch"](function (error) {
72782
- if (error.name === 'NotAllowedError') {
72783
- var _$audioMedia$parentNo;
72784
- // Let's show a play audio button
72785
- $playBtn = document.createElement('button');
72786
- $playBtn.classList.add('play-audio-btn');
72787
- $playBtn.textContent = 'Play Audio';
72788
- $playBtn.addEventListener('click', function () {
72789
- $audioMedia.muted = false;
72790
- $audioMedia.play();
72791
- });
72792
- (_$audioMedia$parentNo = $audioMedia.parentNode) === null || _$audioMedia$parentNo === void 0 || _$audioMedia$parentNo.insertBefore($playBtn, $audioMedia.nextSibling);
72793
- }
72794
- });
72795
- }
72796
- if (media.duration === 0) {
72797
- $audioMedia.ondurationchange = function () {
72798
- console.debug('Showing Media ' + media.id + ' for ' + $audioMedia.duration + 's of Region ' + media.region.regionId);
72799
- };
72800
- $audioMedia.onended = function () {
72801
- var _media$emitter;
72802
- console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has ended playing . . ."));
72803
- (_media$emitter = media.emitter) === null || _media$emitter === void 0 || _media$emitter.emit('end', media);
72804
- };
72805
- }
72806
- }
72807
- }
72808
- };
72809
- return audioMediaObject;
72810
- }
72811
-
72812
73027
  var BlobLoader = /*#__PURE__*/function () {
72813
73028
  function BlobLoader() {
72814
73029
  _classCallCheck(this, BlobLoader);
@@ -72950,418 +73165,754 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
72950
73165
  PreviewTranslations["target"] = "Target";
72951
73166
  })(PreviewTranslations || (PreviewTranslations = {}));
72952
73167
 
72953
- function composeVideoSource($media, media) {
72954
- // const videoSrc = await preloadMediaBlob(media.url as string, media.mediaType as MediaTypes);
72955
- var vidType = videoFileType(getFileExt(media.uri));
72956
- // Only add one source per type
72957
- if ($media.querySelectorAll("source[type=\"".concat(vidType, "\"]")).length === 0) {
72958
- var $videoSource = document.createElement('source');
72959
- $videoSource.src = media.url;
72960
- $videoSource.type = vidType;
72961
- $media.insertBefore($videoSource, $media.lastElementChild);
73168
+ function nextId(options) {
73169
+ if (options.idCounter > 500) {
73170
+ options.idCounter = 0;
72962
73171
  }
72963
- return $media;
73172
+ options.idCounter = options.idCounter + 1;
73173
+ return options.idCounter;
72964
73174
  }
72965
- var defaultVjsOpts = {
72966
- autoplay: false,
72967
- muted: true,
72968
- // Start muted to allow autoplay policies
72969
- preload: 'auto',
72970
- controls: false
73175
+ var getMediaId = function getMediaId(_ref) {
73176
+ var mediaType = _ref.mediaType,
73177
+ containerName = _ref.containerName;
73178
+ var mediaId = containerName;
73179
+ if (mediaType === 'video') {
73180
+ mediaId = mediaId + '-vid';
73181
+ } else if (mediaType === 'audio') {
73182
+ mediaId = mediaId + '-aud';
73183
+ }
73184
+ return mediaId;
72971
73185
  };
72972
- var vjsDefaultOptions = function vjsDefaultOptions(opts) {
72973
- return _objectSpread2({
72974
- controls: false,
72975
- preload: 'auto',
72976
- autoplay: false,
72977
- muted: true
72978
- }, opts);
73186
+ var capitalizeStr = function capitalizeStr(inputStr) {
73187
+ if (inputStr === null) {
73188
+ return '';
73189
+ }
73190
+ return String(inputStr).charAt(0).toUpperCase() + String(inputStr).substring(1);
72979
73191
  };
72980
- function videoMediaHandler(media, platform) {
72981
- var videoPlayer = {
72982
- player: undefined,
72983
- duration: 0,
72984
- stop: function stop(disposeOnly) {}
72985
- };
72986
- var playerReportFault = /*#__PURE__*/function () {
72987
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(msg) {
72988
- var playerSW, hasSW;
72989
- return _regeneratorRuntime().wrap(function _callee$(_context) {
72990
- while (1) switch (_context.prev = _context.next) {
72991
- case 0:
72992
- // Immediately expire media and report a fault
72993
- playerSW = PwaSW();
72994
- _context.next = 3;
72995
- return playerSW.getSW();
72996
- case 3:
72997
- hasSW = _context.sent;
72998
- media.region.layout.state = exports.ELayoutState.ERROR;
72999
- media.region.layout.errorCode = 405;
73000
- if (hasSW) {
73001
- playerSW.postMsg({
73002
- type: 'MEDIA_FAULT',
73003
- code: 5002,
73004
- reason: msg,
73005
- mediaId: media.id,
73006
- regionId: media.region.id,
73007
- layoutId: media.region.layout.id,
73008
- date: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
73009
- // Temporary setting
73010
- expires: format(new Date(setExpiry(1)), 'yyyy-MM-dd HH:mm:ss')
73011
- })["finally"](function () {
73012
- videoPlayer.stop();
73013
- });
73014
- } else {
73015
- videoPlayer.stop();
73192
+ function getDataBlob(_x, _x2) {
73193
+ return _getDataBlob.apply(this, arguments);
73194
+ }
73195
+ function _getDataBlob() {
73196
+ _getDataBlob = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(src, jwtToken) {
73197
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
73198
+ while (1) switch (_context3.prev = _context3.next) {
73199
+ case 0:
73200
+ return _context3.abrupt("return", fetch(src, {
73201
+ method: 'GET',
73202
+ headers: {
73203
+ 'X-PREVIEW-JWT': jwtToken || ''
73016
73204
  }
73017
- case 7:
73018
- case "end":
73019
- return _context.stop();
73020
- }
73021
- }, _callee);
73022
- }));
73023
- return function playerReportFault(_x) {
73024
- return _ref.apply(this, arguments);
73025
- };
73026
- }();
73027
- videoPlayer.duration = media.duration;
73028
- if (media.player) {
73029
- videoPlayer.player = media.player;
73030
- } else {
73031
- // Load on demand if it has not been cached
73032
- var vjsElem = media.html;
73033
- var vidType = videoFileType(getFileExt(media.uri));
73034
- if (vjsElem === null) {
73035
- // Use media containerName instead for VJS id
73036
- vjsElem = media.containerName;
73037
- }
73038
- videoPlayer.player = videojs(vjsElem, _objectSpread2(_objectSpread2({}, defaultVjsOpts), {}, {
73039
- sources: [{
73040
- src: media.url,
73041
- type: vidType
73042
- }]
73043
- }));
73044
- media.player = videoPlayer.player;
73045
- }
73046
- videoPlayer.stop = function () {
73047
- var disposeOnly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
73048
- // Expire the media and dispose the video
73049
- if (videoPlayer.player !== undefined) {
73050
- if (!disposeOnly) {
73051
- media.emitter.emit('end', media);
73205
+ }).then(function (res) {
73206
+ return res.blob();
73207
+ }).then(function (blob) {
73208
+ return new Promise(function (res, rej) {
73209
+ var reader = new FileReader();
73210
+ reader.onloadend = function () {
73211
+ return res(reader.result);
73212
+ };
73213
+ reader.onerror = rej;
73214
+ reader.readAsDataURL(blob);
73215
+ });
73216
+ }));
73217
+ case 1:
73218
+ case "end":
73219
+ return _context3.stop();
73052
73220
  }
73053
- // Dispose player
73054
- videoPlayer.player.dispose();
73055
- // Clear up media player
73056
- videoPlayer.player = undefined;
73057
- media.player = undefined;
73058
- }
73059
- };
73060
- videoPlayer.player.on('loadstart', function () {
73061
- console.debug("??? XLR.debug >> VideoMedia - ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has started loading data . . ."));
73062
- });
73063
- videoPlayer.player.one('loadedmetadata', function () {
73064
- if (media.duration === 0 && videoPlayer.player !== undefined) {
73065
- videoPlayer.duration = videoPlayer.player.duration();
73066
- }
73067
- console.debug('??? XLR.debug >> VideoMedia - loadedmetadata: Setting video duration to = ' + videoPlayer.duration);
73068
- });
73069
- videoPlayer.player.one('playing', function () {
73070
- console.debug('??? XLR.debug >> VideoMedia - playing: Showing Media ' + media.id + ' for ' + videoPlayer.duration + 's of Region ' + media.region.regionId);
73071
- console.debug("??? XLR.debug >> VideoMedia - ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " is now playing . . ."));
73072
- videoPlayer.player && videoPlayer.player.muted(media.muted);
73073
- });
73074
- videoPlayer.player.on('error', /*#__PURE__*/function () {
73075
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(err) {
73076
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
73077
- while (1) switch (_context2.prev = _context2.next) {
73078
- case 0:
73079
- console.debug("??? XLR.debug >> VideoMedia - Media Error: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id));
73080
- if (!(platform === 'chromeOS')) {
73081
- _context2.next = 6;
73082
- break;
73221
+ }, _callee3);
73222
+ }));
73223
+ return _getDataBlob.apply(this, arguments);
73224
+ }
73225
+ function preloadMediaBlob(_x3, _x4, _x5) {
73226
+ return _preloadMediaBlob.apply(this, arguments);
73227
+ }
73228
+ function _preloadMediaBlob() {
73229
+ _preloadMediaBlob = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(src, type, jwtToken) {
73230
+ var res, blob, data;
73231
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
73232
+ while (1) switch (_context4.prev = _context4.next) {
73233
+ case 0:
73234
+ _context4.next = 2;
73235
+ return fetch(src, {
73236
+ method: 'GET',
73237
+ headers: {
73238
+ 'X-PREVIEW-JWT': jwtToken || ''
73083
73239
  }
73084
- _context2.next = 4;
73085
- return playerReportFault('Video file source not supported');
73086
- case 4:
73087
- _context2.next = 7;
73240
+ });
73241
+ case 2:
73242
+ res = _context4.sent;
73243
+ blob = new Blob();
73244
+ if (!(type === 'image')) {
73245
+ _context4.next = 8;
73088
73246
  break;
73089
- case 6:
73090
- // End media after 5 seconds
73091
- setTimeout(function () {
73092
- console.debug("??? XLR.debug >> VideoMedia - ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has ended . . ."));
73093
- videoPlayer.stop();
73094
- }, 5000);
73095
- case 7:
73096
- case "end":
73097
- return _context2.stop();
73098
- }
73099
- }, _callee2);
73100
- }));
73101
- return function (_x2) {
73102
- return _ref2.apply(this, arguments);
73103
- };
73104
- }());
73105
- // Register on.("end") when media.duration is 0
73106
- if (media.duration === 0) {
73107
- videoPlayer.player.on('ended', function () {
73108
- console.debug("??? XLR.debug >> VideoMedia - onended: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has ended playing . . ."));
73109
- videoPlayer.stop();
73110
- });
73111
- }
73112
- return videoPlayer;
73113
- }
73114
- function VideoMedia(media, xlr) {
73115
- var mediaId = getMediaId(media);
73116
- var videoPlayer = {
73117
- duration: 0,
73118
- init: function init() {
73119
- var _this = this;
73120
- var triggerTimeUpdate = false; // Used for media.duration === 0
73121
- videoPlayer.duration = media.duration;
73122
- var vjsPlayer = videojs(mediaId);
73123
- if (vjsPlayer) {
73124
- vjsPlayer.on('loadstart', function () {
73125
- console.debug("??? XLR.debug >> VideoMedia: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has started loading data . . ."));
73126
- });
73127
- vjsPlayer.on('loadedmetadata', function () {
73128
- if (media.duration === 0) {
73129
- videoPlayer.duration = vjsPlayer.duration();
73130
- }
73131
- console.debug('??? XLR.debug >> VideoMedia: loadedmetadata: Setting video duration to = ' + videoPlayer.duration);
73132
- });
73133
- vjsPlayer.on('canplay', function () {
73134
- console.debug("??? XLR.debug >> VideoMedia: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " can be played . . ."));
73135
- });
73136
- vjsPlayer.on('playing', function () {
73137
- // Update duration
73138
- if (videoPlayer.duration === 0) {
73139
- videoPlayer.duration = vjsPlayer.duration();
73140
73247
  }
73141
- console.debug('??? XLR.debug >> VideoMedia: playing: Showing Media ' + media.id + ' for ' + videoPlayer.duration + 's of Region ' + media.region.regionId);
73142
- console.debug("??? XLR.debug >> VideoMedia: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " is now playing . . ."));
73143
- });
73144
- // @NOTE: When video is paused due to fail in unmuting the video
73145
- // and video has media.duration = 0, the video will stay paused and the video cycle won't end
73146
- // @TODO: Add timer when video is paused due to unmuting fail and duration that is equal to 0
73147
- // @NOTE: The pause issue when unmuting the video is mainly on a browser level.
73148
- // Please visit https://developer.chrome.com/blog/autoplay/ for more info.
73149
- vjsPlayer.ready(function () {
73150
- // Add guard making sure that video element is present
73151
- var videoElem = document.querySelector(".media--item.".concat(mediaId));
73152
- if (!document.body.contains(videoElem)) {
73153
- media.emitter.emit('cancelled', media);
73154
- return;
73248
+ blob = new Blob();
73249
+ _context4.next = 19;
73250
+ break;
73251
+ case 8:
73252
+ if (!(type === 'video')) {
73253
+ _context4.next = 14;
73254
+ break;
73155
73255
  }
73156
- if (vjsPlayer !== undefined) {
73157
- vjsPlayer.muted(true);
73158
- // Race promise between a 0.5s play and a 5s skip
73159
- Promise.race([new Promise(function (resolve, reject) {
73160
- return setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
73161
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
73162
- while (1) switch (_context3.prev = _context3.next) {
73163
- case 0:
73164
- console.debug("??? XLR.debug >> VideoMedia: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Trying to force play after 0.1 seconds"));
73165
- // Try to force play here
73166
- _context3.prev = 1;
73167
- if (!(vjsPlayer.currentTime() === 0)) {
73168
- _context3.next = 6;
73169
- break;
73170
- }
73171
- // Set video mute/unmute based on setting once playing
73172
- vjsPlayer.muted(media.muted);
73173
- _context3.next = 6;
73174
- return vjsPlayer.play();
73175
- case 6:
73176
- // Resolve if play works
73177
- resolve(true);
73178
- _context3.next = 12;
73179
- break;
73180
- case 9:
73181
- _context3.prev = 9;
73182
- _context3.t0 = _context3["catch"](1);
73183
- // Reject race if play fails
73184
- reject('Play failed');
73185
- case 12:
73186
- case "end":
73187
- return _context3.stop();
73188
- }
73189
- }, _callee3, null, [[1, 9]]);
73190
- })), 100);
73191
- }), new Promise(function (_, reject) {
73192
- return setTimeout(function () {
73193
- return reject('Timeout');
73194
- }, 5000);
73195
- })]).then(function () {
73196
- console.debug("??? XLR.debug >> VideoMedia: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Autoplay started"));
73197
- })["catch"]( /*#__PURE__*/function () {
73198
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(error) {
73199
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
73200
- while (1) switch (_context4.prev = _context4.next) {
73201
- case 0:
73202
- if (error === 'Timeout') {
73203
- console.debug("??? XLR.debug >> VideoMedia: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Promise not resolved within 5 seconds. Move to next media"));
73204
- _this.stop();
73205
- } else {
73206
- console.debug("??? XLR.debug >> VideoMedia: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Autoplay error: ").concat(error));
73207
- if (xlr.config.platform === exports.ConsumerPlatform.CHROMEOS) {
73208
- playerReportFault('Media autoplay error', media).then(function () {
73209
- _this.stop();
73210
- });
73211
- }
73212
- }
73213
- case 1:
73214
- case "end":
73215
- return _context4.stop();
73216
- }
73217
- }, _callee4);
73218
- }));
73219
- return function (_x3) {
73220
- return _ref4.apply(this, arguments);
73221
- };
73222
- }());
73223
- // Optional: Reset the flag automatically when a new video loads or the source changes
73224
- vjsPlayer.on('loadstart', function () {
73225
- triggerTimeUpdate = false;
73226
- });
73227
- if (media.duration === 0) {
73228
- vjsPlayer.on('timeupdate', function () {
73229
- var preloadBufferTimeMs = 2000;
73230
- var mediaDuration = vjsPlayer.duration();
73231
- var currentTime = vjsPlayer.currentTime();
73232
- var regionHasMultipleMedia = media.region.totalMediaObjects > 1;
73233
- var remainingTimeMs = 0;
73234
- if (mediaDuration !== undefined && currentTime !== undefined) {
73235
- remainingTimeMs = (mediaDuration - currentTime) * 1000;
73236
- }
73237
- if (regionHasMultipleMedia && remainingTimeMs === 0 && !triggerTimeUpdate) {
73238
- // We don't have data yet and we must immediately prepare next media
73239
- media.region.prepareNextMedia();
73240
- } else if (regionHasMultipleMedia && remainingTimeMs <= preloadBufferTimeMs && !triggerTimeUpdate) {
73241
- // Check if remaining time is less than preloadBufferTimeMs and the action hasn't been triggered yet
73242
- console.log('Less than preloadBufferTimeMs remaining! Do something now.');
73243
- // Prepare next media in region
73244
- media.region.prepareNextMedia();
73245
- triggerTimeUpdate = true; // Set the flag to prevent re-triggering
73246
- }
73247
- // Reset the flag if the user seeks back to a point where more than preloadBufferTimeMs remain
73248
- if (remainingTimeMs > preloadBufferTimeMs) {
73249
- triggerTimeUpdate = false;
73250
- }
73251
- });
73252
- }
73256
+ _context4.next = 11;
73257
+ return res.blob();
73258
+ case 11:
73259
+ blob = _context4.sent;
73260
+ _context4.next = 19;
73261
+ break;
73262
+ case 14:
73263
+ if (!(type === 'audio')) {
73264
+ _context4.next = 19;
73265
+ break;
73253
73266
  }
73254
- });
73255
- vjsPlayer.on('error', /*#__PURE__*/function () {
73256
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(err) {
73257
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
73258
- while (1) switch (_context5.prev = _context5.next) {
73259
- case 0:
73260
- console.debug("??? XLR.debug >> VideoMedia: Media Error: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id));
73261
- if (xlr.config.platform === exports.ConsumerPlatform.CHROMEOS) {
73262
- playerReportFault('Video file source not supported', media).then(function () {
73263
- _this.stop();
73264
- });
73265
- } else {
73266
- // End media after 5 seconds
73267
- setTimeout(function () {
73268
- console.debug("??? XLR.debug >> VideoMedia: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has ended . . ."));
73269
- _this.stop();
73270
- }, 5000);
73271
- }
73272
- case 2:
73273
- case "end":
73274
- return _context5.stop();
73275
- }
73276
- }, _callee5);
73277
- }));
73278
- return function (_x4) {
73279
- return _ref5.apply(this, arguments);
73280
- };
73281
- }());
73282
- if (media.duration === 0) {
73283
- vjsPlayer.on('ended', function () {
73284
- console.debug("??? XLR.debug >> VideoMedia: onended: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has ended playing . . ."));
73285
- _this.stop();
73267
+ _context4.next = 17;
73268
+ return res.arrayBuffer();
73269
+ case 17:
73270
+ data = _context4.sent;
73271
+ blob = new Blob([data], {
73272
+ type: audioFileType(getFileExt(src))
73286
73273
  });
73287
- }
73274
+ case 19:
73275
+ return _context4.abrupt("return", URL.createObjectURL(blob));
73276
+ case 20:
73277
+ case "end":
73278
+ return _context4.stop();
73288
73279
  }
73289
- },
73290
- stop: function stop() {
73291
- var disposeOnly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
73292
- var vjsPlayer = media.player;
73293
- console.debug('??? XLR.debug >> VideoMedia::stop', {
73294
- vjsPlayer: vjsPlayer,
73295
- isDisposed: vjsPlayer === null || vjsPlayer === void 0 ? void 0 : vjsPlayer.isDisposed_,
73296
- el: vjsPlayer === null || vjsPlayer === void 0 ? void 0 : vjsPlayer.el_
73297
- });
73298
- // Expire the media and dispose the video
73299
- if (vjsPlayer !== undefined && !vjsPlayer.isDisposed_) {
73300
- if (!disposeOnly) {
73301
- media.emitter.emit('end', media);
73302
- }
73303
- vjsPlayer.dispose();
73304
- // Clear up media player
73305
- media.player = undefined;
73306
- } else {
73307
- media.player = undefined;
73308
- media.html = null;
73309
- media.emitter.emit('end', media);
73280
+ }, _callee4);
73281
+ }));
73282
+ return _preloadMediaBlob.apply(this, arguments);
73283
+ }
73284
+ function fetchJSON(_x6, _x7) {
73285
+ return _fetchJSON.apply(this, arguments);
73286
+ }
73287
+ function _fetchJSON() {
73288
+ _fetchJSON = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(url, jwtToken) {
73289
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
73290
+ while (1) switch (_context5.prev = _context5.next) {
73291
+ case 0:
73292
+ return _context5.abrupt("return", fetch(url, {
73293
+ method: 'GET',
73294
+ headers: {
73295
+ 'X-PREVIEW-JWT': jwtToken || ''
73296
+ }
73297
+ }).then(function (res) {
73298
+ return res.json();
73299
+ })["catch"](function (err) {
73300
+ console.debug(err);
73301
+ }));
73302
+ case 1:
73303
+ case "end":
73304
+ return _context5.stop();
73310
73305
  }
73311
- },
73312
- play: function play() {
73313
- var _this2 = this;
73314
- var vjsPlayer = videojs(mediaId);
73315
- if (vjsPlayer !== undefined) {
73316
- var _vjsPlayer$play;
73317
- (_vjsPlayer$play = vjsPlayer.play()) === null || _vjsPlayer$play === void 0 || _vjsPlayer$play["catch"]( /*#__PURE__*/function () {
73318
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(error) {
73319
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
73320
- while (1) switch (_context6.prev = _context6.next) {
73321
- case 0:
73322
- if (error === 'Timeout') {
73323
- console.debug("??? XLR.debug >> VideoMedia: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Promise not resolved within 5 seconds. Move to next media"));
73324
- _this2.stop();
73325
- } else {
73326
- console.debug("??? XLR.debug >> VideoMedia: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Autoplay error: ").concat(error));
73327
- if (xlr.config.platform === exports.ConsumerPlatform.CHROMEOS) {
73328
- playerReportFault('Media autoplay error', media).then(function () {
73329
- _this2.stop();
73330
- });
73331
- }
73332
- }
73333
- case 1:
73334
- case "end":
73335
- return _context6.stop();
73336
- }
73337
- }, _callee6);
73306
+ }, _callee5);
73307
+ }));
73308
+ return _fetchJSON.apply(this, arguments);
73309
+ }
73310
+ function fetchText(_x8, _x9) {
73311
+ return _fetchText.apply(this, arguments);
73312
+ }
73313
+ function _fetchText() {
73314
+ _fetchText = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(url, jwtToken) {
73315
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
73316
+ while (1) switch (_context6.prev = _context6.next) {
73317
+ case 0:
73318
+ return _context6.abrupt("return", fetch(url, {
73319
+ method: 'GET',
73320
+ headers: {
73321
+ 'X-PREVIEW-JWT': jwtToken || ''
73322
+ }
73323
+ }).then(function (res) {
73324
+ return res.text();
73325
+ }).then(function (responseText) {
73326
+ if (String(responseText).length > 0) {
73327
+ return responseText;
73328
+ } else {
73329
+ return '';
73330
+ }
73331
+ })["catch"](function (err) {
73332
+ console.debug(err);
73333
+ return err === null || err === void 0 ? void 0 : err.message;
73338
73334
  }));
73339
- return function (_x5) {
73340
- return _ref6.apply(this, arguments);
73341
- };
73342
- }());
73335
+ case 1:
73336
+ case "end":
73337
+ return _context6.stop();
73343
73338
  }
73339
+ }, _callee6);
73340
+ }));
73341
+ return _fetchText.apply(this, arguments);
73342
+ }
73343
+ function getFileExt(filename) {
73344
+ var filenameArr = String(filename).split('.');
73345
+ return filenameArr[filenameArr.length - 1];
73346
+ }
73347
+ function audioFileType(str) {
73348
+ var validAudioTypes = {
73349
+ 'mp3': 'audio/mp3',
73350
+ 'wav': 'audio/wav',
73351
+ 'ogg': 'audio/ogg'
73352
+ };
73353
+ if (Boolean(validAudioTypes[str])) {
73354
+ return validAudioTypes[str];
73355
+ }
73356
+ return undefined;
73357
+ }
73358
+ function videoFileType(str) {
73359
+ var validVideoTypes = {
73360
+ 'mp4': 'video/mp4',
73361
+ 'webm': 'video/webm',
73362
+ 'wmv': 'video/x-ms-wmv'
73363
+ };
73364
+ if (Boolean(validVideoTypes[str])) {
73365
+ return validVideoTypes[str];
73366
+ }
73367
+ return undefined;
73368
+ }
73369
+ function composeResourceUrlByPlatform(options, params) {
73370
+ var resourceUrl = '';
73371
+ if (params.regionOptions && Boolean(params.regionOptions.getResourceUrl)) {
73372
+ resourceUrl = params.regionOptions.getResourceUrl.replace(":regionId", params.regionId).replace(":id", params.mediaId) + '?preview=1&layoutPreview=1';
73373
+ }
73374
+ if (options.platform === exports.ConsumerPlatform.CMS && Boolean(params.regionOptions.previewJwt)) {
73375
+ resourceUrl += '&jwt=' + params.regionOptions.previewJwt;
73376
+ }
73377
+ if (options.platform === exports.ConsumerPlatform.CHROMEOS) {
73378
+ var resourceEndpoint = '/required-files/resource/';
73379
+ if (!params.isGlobalContent && params.isImageOrVideo) {
73380
+ resourceUrl = resourceEndpoint + params.fileId + '?saveAs=' + params.uri;
73381
+ }
73382
+ } else if (options.platform === exports.ConsumerPlatform.ELECTRON) {
73383
+ if (params.render === 'html' || params.mediaType === 'ticker' || params.mediaType === 'webpage') {
73384
+ resourceUrl = options.appHost + 'layout_' + params.layoutId + '_region_' + params.regionId + '_media_' + params.mediaId + '.html';
73385
+ } else if (params.render === 'native' && params.isImageOrVideo) {
73386
+ resourceUrl = options.appHost + params.uri;
73344
73387
  }
73388
+ } else if (!Boolean(params['mediaType'])) {
73389
+ resourceUrl += '&scale_override=' + params.scaleFactor;
73390
+ }
73391
+ return resourceUrl;
73392
+ }
73393
+ function composeResourceUrl(options, params) {
73394
+ var _options$config, _options$config2, _options$config3;
73395
+ var schemaVersion = options && ((_options$config = options.config) === null || _options$config === void 0 ? void 0 : _options$config.schemaVersion);
73396
+ var hardwareKey = options && ((_options$config2 = options.config) === null || _options$config2 === void 0 ? void 0 : _options$config2.hardwareKey);
73397
+ var serverKey = options && ((_options$config3 = options.config) === null || _options$config3 === void 0 ? void 0 : _options$config3.cmsKey);
73398
+ return '/pwa/getResource' + '?v=' + schemaVersion + '&serverKey=' + serverKey + '&hardwareKey=' + hardwareKey + '&layoutId=' + params.layoutId + '&regionId=' + params.regionId + '&mediaId=' + params.mediaId;
73399
+ }
73400
+ function composeMediaUrl(params) {
73401
+ return '/xmds.php?file=' + params.uri;
73402
+ }
73403
+ function composeBgUrlByPlatform(platform, params) {
73404
+ var bgImageUrl = '';
73405
+ if (platform === exports.ConsumerPlatform.CMS) {
73406
+ bgImageUrl = params.options.layoutBackgroundDownloadUrl.replace(":id", params.id) + '&preview=1&width=' + params.sWidth + '&height=' + params.sHeight + '&dynamic&proportional=0';
73407
+ } else if (platform === exports.ConsumerPlatform.CHROMEOS) {
73408
+ bgImageUrl = composeMediaUrl({
73409
+ uri: params.bgImage
73410
+ });
73411
+ } else if (platform === exports.ConsumerPlatform.ELECTRON) {
73412
+ bgImageUrl = params.options.appHost + params.bgImage;
73413
+ }
73414
+ return bgImageUrl;
73415
+ }
73416
+ function getIndexByLayoutId(layoutsInput, layoutId) {
73417
+ var layoutIndexes = layoutsInput.reduce(function (a, b, indx) {
73418
+ a[Number(b.layoutId)] = _objectSpread2(_objectSpread2({}, b), {}, {
73419
+ index: indx
73420
+ });
73421
+ return a;
73422
+ }, {});
73423
+ if (layoutId === null || !layoutId) {
73424
+ return layoutIndexes;
73425
+ }
73426
+ if (Boolean(layoutIndexes[layoutId])) {
73427
+ return layoutIndexes[layoutId];
73428
+ }
73429
+ // Defaults to 0
73430
+ return {
73431
+ index: 0
73345
73432
  };
73346
- return videoPlayer;
73347
73433
  }
73348
-
73349
- var Media = /*#__PURE__*/function () {
73350
- function Media(region, mediaId, xml, options, xlr) {
73351
- var _this$xml,
73352
- _this$xml2,
73353
- _this$xml3,
73354
- _this$xml4,
73355
- _this$xml5,
73356
- _this = this;
73357
- _classCallCheck(this, Media);
73358
- _defineProperty(this, "attachedAudio", false);
73359
- _defineProperty(this, "checkIframeStatus", false);
73360
- _defineProperty(this, "containerName", '');
73361
- _defineProperty(this, "divHeight", 0);
73362
- _defineProperty(this, "divWidth", 0);
73363
- _defineProperty(this, "duration", 0);
73364
- _defineProperty(this, "emitter", createNanoEvents());
73434
+ function isEmpty(input) {
73435
+ return !Boolean(input) || String(input).length === 0;
73436
+ }
73437
+ function getAllAttributes(elem) {
73438
+ if (!elem || elem === null) {
73439
+ return {};
73440
+ }
73441
+ return elem.getAttributeNames().reduce(function (obj, name) {
73442
+ return _objectSpread2(_objectSpread2({}, obj), {}, _defineProperty({}, name, {
73443
+ value: elem.getAttribute(name)
73444
+ }));
73445
+ }, {});
73446
+ }
73447
+ /**
73448
+ * Create expiration day based on current date
73449
+ * @param numDays Number of days as expiry
73450
+ * @returns JSON string format of date
73451
+ */
73452
+ function setExpiry(numDays) {
73453
+ var today = new Date();
73454
+ return new Date(today.setHours(24 * numDays || 1)).toJSON();
73455
+ }
73456
+ /**
73457
+ * Check if given layout exists in the loop using layoutId
73458
+ * @param layouts Schedule loop unique layouts (uniqueLayouts)
73459
+ * @param layoutId Layout ID of the layout to look for
73460
+ *
73461
+ * @return boolean
73462
+ */
73463
+ function isLayoutValid(layouts, layoutId) {
73464
+ if (layouts.length < 1 || !layoutId) {
73465
+ return false;
73466
+ }
73467
+ var layoutIndex = layouts.findIndex(function (l) {
73468
+ return l.layoutId === layoutId;
73469
+ });
73470
+ return layoutIndex !== -1;
73471
+ }
73472
+ function getLayoutIndexByLayoutId(layouts, layoutId) {
73473
+ if (layouts.length < 1 || !layoutId) {
73474
+ return null;
73475
+ }
73476
+ return layouts.findIndex(function (l) {
73477
+ return l.layoutId === layoutId;
73478
+ });
73479
+ }
73480
+ function hasDefaultOnly(inputLayouts) {
73481
+ var _inputLayouts$0$respo;
73482
+ if (!inputLayouts) {
73483
+ return false;
73484
+ }
73485
+ return inputLayouts.length === 1 && ((_inputLayouts$0$respo = inputLayouts[0].response) === null || _inputLayouts$0$respo === void 0 ? void 0 : _inputLayouts$0$respo.nodeName) === 'default';
73486
+ }
73487
+ function hasSspLayout(inputLayouts) {
73488
+ var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
73489
+ if (!inputLayouts || inputLayouts.length === 0) {
73490
+ return defaultValue;
73491
+ }
73492
+ return inputLayouts.find(function (layout) {
73493
+ return layout.layoutId === -1;
73494
+ }) !== undefined;
73495
+ }
73496
+ function prepareIframe(media) {
73497
+ var iframe = document.createElement('iframe');
73498
+ iframe.scrolling = 'no';
73499
+ iframe.id = media.iframeName;
73500
+ iframe.width = "".concat(media.divWidth, "px");
73501
+ iframe.height = "".concat(media.divHeight, "px");
73502
+ iframe.style.cssText = "border: 0;";
73503
+ if ((media.render === 'html' || media.render === 'webpage') && media.url !== null) {
73504
+ iframe.src = media.url;
73505
+ } else {
73506
+ iframe.src = "".concat(media.url, "&width=").concat(media.divWidth, "&height=").concat(media.divHeight);
73507
+ }
73508
+ return iframe;
73509
+ }
73510
+ function prepareImage(media, container) {
73511
+ if (media.options['scaletype'] === 'stretch') {
73512
+ container.style.cssText = container.style.cssText.concat("background-size: 100% 100%;");
73513
+ } else if (media.options['scaletype'] === 'fit') {
73514
+ container.style.cssText = container.style.cssText.concat("background-size: cover;");
73515
+ } else {
73516
+ // Center scale type, do we have align or valign?
73517
+ var align = media.options['align'] == "" ? "center" : media.options['align'];
73518
+ var valign = media.options['valign'] == "" || media.options['valign'] == "middle" ? "center" : media.options['valign'];
73519
+ container.style.cssText = container.style.cssText.concat("background-position: ".concat(align, " ").concat(valign));
73520
+ }
73521
+ return container;
73522
+ }
73523
+ function prepareVideo(media, container) {
73524
+ var $videoMedia = composeVideoSource(container, media);
73525
+ var isMuted = false;
73526
+ if (Boolean(media.options['mute'])) {
73527
+ isMuted = media.options.mute === '1';
73528
+ }
73529
+ if (Boolean(media.options['scaletype'])) {
73530
+ if (media.options.scaletype === 'stretch') {
73531
+ $videoMedia.style.objectFit = 'fill';
73532
+ }
73533
+ }
73534
+ $videoMedia.classList.add('video-js', 'vjs-default-skin');
73535
+ if (media.loop) {
73536
+ media.loop = true;
73537
+ $videoMedia.loop = true;
73538
+ }
73539
+ media.muted = isMuted;
73540
+ return $videoMedia;
73541
+ }
73542
+ function prepareAudio(media, container) {
73543
+ var $audioMedia = container;
73544
+ $audioMedia.preload = 'auto';
73545
+ $audioMedia.textContent = 'Unsupported Audio';
73546
+ $audioMedia.autoplay = true;
73547
+ if (media.loop) {
73548
+ $audioMedia.loop = true;
73549
+ }
73550
+ return $audioMedia;
73551
+ }
73552
+ function createMediaElement(mediaObject) {
73553
+ var self = mediaObject;
73554
+ var mediaId = getMediaId(self);
73555
+ var mediaSelector = ".media--item.".concat(mediaId);
73556
+ var $media = self.region.html.querySelector(mediaSelector);
73557
+ if ($media === null) {
73558
+ if (self.mediaType === 'video') {
73559
+ $media = document.createElement('video');
73560
+ } else if (self.mediaType === 'audio') {
73561
+ $media = new Audio();
73562
+ } else {
73563
+ $media = document.createElement('div');
73564
+ }
73565
+ $media.id = mediaId;
73566
+ }
73567
+ $media.dataset.mediaId = self.id;
73568
+ $media.dataset.mediaType = self.mediaType;
73569
+ $media.dataset.type = self.type;
73570
+ $media.dataset.render = self.render;
73571
+ $media.dataset.duration = String(self.duration);
73572
+ $media.dataset.fileId = self.fileId;
73573
+ $media.className = "media--item ".concat(mediaId);
73574
+ /* Scale the Content Container */
73575
+ var cssText = "\n width: ".concat(self.divWidth, "px;\n height: ").concat(self.divHeight, "px;\n position: absolute;\n background-size: contain;\n background-repeat: no-repeat;\n background-position: center;\n ");
73576
+ if (self.mediaType !== 'video') {
73577
+ cssText += "\n visibility: hidden;\n opacity: 0;\n z-index: 0;\n ";
73578
+ }
73579
+ $media.style.cssText = cssText;
73580
+ if (self.render === 'html' || self.mediaType === 'ticker' || self.mediaType === 'webpage') {
73581
+ self.checkIframeStatus = true;
73582
+ self.iframe = prepareIframe(self);
73583
+ } else if (self.mediaType === "image") {
73584
+ $media = prepareImage(self, $media);
73585
+ } else if (self.mediaType === 'video') {
73586
+ $media = prepareVideo(self, $media);
73587
+ } else if (self.mediaType === 'audio') {
73588
+ $media = prepareAudio(self, $media);
73589
+ }
73590
+ // Duration is per item condition
73591
+ if ((self.render === 'html' || self.mediaType === 'ticker') && self.url !== null) {
73592
+ /* Check if the ticker duration is based on the number of items in the feed */
73593
+ if (self.options['durationisperitem'] === '1') {
73594
+ var regex = new RegExp('<!-- NUMITEMS=(.*?) -->');
73595
+ _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
73596
+ var html, res;
73597
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
73598
+ while (1) switch (_context.prev = _context.next) {
73599
+ case 0:
73600
+ _context.next = 2;
73601
+ return fetchJSON("".concat(self.url, "&width=").concat(self.divWidth, "&height=").concat(self.divHeight), self.options.previewJwt);
73602
+ case 2:
73603
+ html = _context.sent;
73604
+ console.debug({
73605
+ html: html
73606
+ });
73607
+ res = regex.exec(html);
73608
+ if (res !== null) {
73609
+ self.duration = parseInt(String(self.duration)) * parseInt(res[1]);
73610
+ }
73611
+ case 6:
73612
+ case "end":
73613
+ return _context.stop();
73614
+ }
73615
+ }, _callee);
73616
+ }))();
73617
+ }
73618
+ }
73619
+ // Check if the media has fade-in/out transitions
73620
+ if (Boolean(self.options['transin']) && Boolean(self.options['transinduration'])) {
73621
+ var transInDuration = Number(self.options.transinduration);
73622
+ var fadeInTrans = transitionElement('fadeIn', {
73623
+ duration: transInDuration
73624
+ });
73625
+ $media.animate(fadeInTrans.keyframes, fadeInTrans.timing);
73626
+ }
73627
+ // Add media to the region
73628
+ // Second media if exists, will be off-canvas
73629
+ // All added media will be hidden by default
73630
+ // It will start showing when region.nextMedia() function is called
73631
+ // When there's only 1 item and loop = false, don't remove the item but leave it at its last state
73632
+ // For image, and only 1 item, it should still have the transition for next state
73633
+ // Add conditions for video duration being 0 or 1 and also the loop property
73634
+ // For video url, we have to create a URL out of the XLF video URL
73635
+ /**
73636
+ * @DONE
73637
+ * Case 1: Video duration = 0, this will play the video for its entire duration
73638
+ * Case 2: Video duration is set > 0 and loop = false
73639
+ * E.g. Set duration = 100s, video duration = 62s
73640
+ * the video will play until 62s and will stop to its last frame until 100s
73641
+ * After 100s, it will expire
73642
+ * Case 3: Video duration is set > 0 and loop = true
73643
+ * E.g. Set duration = 100s, video duration = 62s, loop = true
73644
+ * the video will play until 62s and will loop through until the remaining 38s
73645
+ * to complete the 100s set duration
73646
+ */
73647
+ // Add html node to media for
73648
+ // self.html = $media;
73649
+ return $media;
73650
+ }
73651
+ function prepareVideoMedia(media, region) {
73652
+ var mediaId = getMediaId(media);
73653
+ // Check if html is ready and is in the DOM
73654
+ if (media.html !== null) {
73655
+ // Clean up video.js instance
73656
+ var existingPlayer = videojs.getPlayer(mediaId);
73657
+ if (existingPlayer !== undefined) {
73658
+ existingPlayer.dispose();
73659
+ media.player = undefined;
73660
+ }
73661
+ var $layout = region.layout.html;
73662
+ var layoutSelector = '#' + region.layout.containerName + '[data-sequence="' + region.layout.index + '"]';
73663
+ var $layoutWithIndex = document.querySelector(layoutSelector);
73664
+ var $region = document.querySelector('#' + region.containerName);
73665
+ var mediaInRegion = $region === null || $region === void 0 ? void 0 : $region.querySelector('.' + mediaId);
73666
+ console.debug('??? XLR.debug >> [Generators::prepareVideoMedia]', {
73667
+ layoutSelector: layoutSelector,
73668
+ $layoutWithIndex: $layoutWithIndex,
73669
+ $region: $region,
73670
+ mediaInRegion: mediaInRegion,
73671
+ mediaHtml: media.html,
73672
+ existingPlayer: existingPlayer,
73673
+ mediaId: mediaId,
73674
+ layoutInDOM: document.body.contains($layout)
73675
+ });
73676
+ if (!mediaInRegion) {
73677
+ media.html = createMediaElement(media);
73678
+ } else {
73679
+ mediaInRegion.remove();
73680
+ media.html = createMediaElement(media);
73681
+ }
73682
+ // Append fresh copy of the media into the region
73683
+ $region !== null && $region.appendChild(media.html);
73684
+ var isMediaInDOM = document.body.contains(media.html);
73685
+ console.debug('??? XLR.debug >> [Generators::prepareVideoMedia]', {
73686
+ isMediaInDOM: isMediaInDOM,
73687
+ mediaHtml: media.html,
73688
+ mediaId: mediaId
73689
+ });
73690
+ // Initialize video.js
73691
+ media.player = videojs(mediaId, _objectSpread2(_objectSpread2({}, defaultVjsOpts), {}, {
73692
+ errorDisplay: region.xlr.config.platform !== exports.ConsumerPlatform.CHROMEOS,
73693
+ loop: media.loop
73694
+ }));
73695
+ media.player.on('error', /*#__PURE__*/function () {
73696
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(err) {
73697
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
73698
+ while (1) switch (_context2.prev = _context2.next) {
73699
+ case 0:
73700
+ if (media.region.xlr.config.platform === exports.ConsumerPlatform.CHROMEOS) {
73701
+ playerReportFault('Video file not supported', media).then(function () {
73702
+ media.emitter.emit('end', media);
73703
+ });
73704
+ }
73705
+ case 1:
73706
+ case "end":
73707
+ return _context2.stop();
73708
+ }
73709
+ }, _callee2);
73710
+ }));
73711
+ return function (_x10) {
73712
+ return _ref3.apply(this, arguments);
73713
+ };
73714
+ }());
73715
+ media.player.el().style.setProperty('visibility', 'hidden');
73716
+ media.player.el().style.setProperty('opacity', '0');
73717
+ media.player.el().style.setProperty('z-index', '-99');
73718
+ }
73719
+ }
73720
+ function prepareImageMedia(media, region) {
73721
+ var mediaId = getMediaId(media);
73722
+ media.html.style.setProperty('background-image', "url(".concat(media.url));
73723
+ // Check if media in region
73724
+ // Remove old copy before inserting fresh copy
73725
+ var mediaInRegion = region.html.querySelector('.' + mediaId);
73726
+ if (mediaInRegion) {
73727
+ mediaInRegion.remove();
73728
+ }
73729
+ // Append media to its region
73730
+ var $region = document.querySelector('#' + region.containerName);
73731
+ $region !== null && $region.appendChild(media.html);
73732
+ }
73733
+ function prepareAudioMedia(media, region) {
73734
+ var mediaId = getMediaId(media);
73735
+ if (media.url !== null) {
73736
+ media.html.src = media.url;
73737
+ }
73738
+ // Check if media in region
73739
+ // Remove old copy before inserting fresh copy of the media
73740
+ var mediaInRegion = region.html.querySelector('.' + mediaId);
73741
+ if (mediaInRegion) {
73742
+ mediaInRegion.remove();
73743
+ }
73744
+ // Append media to its region
73745
+ var $region = document.querySelector('#' + region.containerName);
73746
+ $region !== null && $region.appendChild(media.html);
73747
+ }
73748
+ function prepareHtmlMedia(media, region) {
73749
+ // Set state as false ( for now )
73750
+ media.ready = false;
73751
+ if (media.html) {
73752
+ var mediaId = getMediaId(media);
73753
+ // Clean up old copy of the media
73754
+ // before inserting fresh copy
73755
+ var $layout = document.querySelector("#".concat(region.layout.containerName, "[data-sequence=\"").concat(region.layout.index, "\"]"));
73756
+ var $region = $layout.querySelector('#' + region.containerName);
73757
+ var mediaInRegion = $region.querySelector('.' + mediaId);
73758
+ console.debug('<><> XLR.debug >> [Media] - [Generators::prepareHtmlMedia]', {
73759
+ mediaId: mediaId,
73760
+ mediaInRegion: mediaInRegion
73761
+ });
73762
+ // Append iframe
73763
+ media.html.innerHTML = '';
73764
+ media.html.appendChild(media.iframe);
73765
+ if (!mediaInRegion) {
73766
+ // Add fresh copy of the media into the region
73767
+ var _$region = document.querySelector('#' + region.containerName);
73768
+ _$region !== null && _$region.appendChild(media.html);
73769
+ media.ready = true;
73770
+ }
73771
+ }
73772
+ }
73773
+ function playerReportFault(_x11, _x12) {
73774
+ return _playerReportFault.apply(this, arguments);
73775
+ }
73776
+ function _playerReportFault() {
73777
+ _playerReportFault = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(msg, media) {
73778
+ var playerSW, hasSW;
73779
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
73780
+ while (1) switch (_context7.prev = _context7.next) {
73781
+ case 0:
73782
+ // Immediately expire media and report a fault
73783
+ playerSW = PwaSW();
73784
+ _context7.next = 3;
73785
+ return playerSW.getSW();
73786
+ case 3:
73787
+ hasSW = _context7.sent;
73788
+ if (hasSW) {
73789
+ playerSW.postMsg({
73790
+ type: 'MEDIA_FAULT',
73791
+ code: 5002,
73792
+ reason: msg,
73793
+ mediaId: media.id,
73794
+ regionId: media.region.id,
73795
+ layoutId: media.region.layout.id,
73796
+ date: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
73797
+ // Temporary setting
73798
+ expires: format(new Date(setExpiry(1)), 'yyyy-MM-dd HH:mm:ss')
73799
+ }).then(function () {
73800
+ // We try to prepare next media if we have more than 1 media
73801
+ if (media.region.totalMediaObjects > 1) {
73802
+ media.region.prepareNextMedia();
73803
+ }
73804
+ })["finally"](function () {
73805
+ // Stopping media as we have reported the error as fault
73806
+ console.debug('??? XLR.debug >> VideoMedia - Done reporting media fault', {
73807
+ mediaId: media.id,
73808
+ regionItems: media.region.totalMediaObjects
73809
+ });
73810
+ });
73811
+ }
73812
+ case 5:
73813
+ case "end":
73814
+ return _context7.stop();
73815
+ }
73816
+ }, _callee7);
73817
+ }));
73818
+ return _playerReportFault.apply(this, arguments);
73819
+ }
73820
+ function setLayoutIndex(layout, layoutIndex) {
73821
+ if (!layout || layout.id === null) {
73822
+ return;
73823
+ }
73824
+ layout.index = layoutIndex;
73825
+ return layout;
73826
+ }
73827
+
73828
+ const urlAlphabet =
73829
+ 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
73830
+
73831
+ /* @ts-self-types="./index.d.ts" */
73832
+ let nanoid = (size = 21) => {
73833
+ let id = '';
73834
+ let bytes = crypto.getRandomValues(new Uint8Array((size |= 0)));
73835
+ while (size--) {
73836
+ id += urlAlphabet[bytes[size] & 63];
73837
+ }
73838
+ return id
73839
+ };
73840
+
73841
+ function AudioMedia(media) {
73842
+ var audioMediaObject = {
73843
+ init: function init() {
73844
+ var $audioMedia = document.getElementById(getMediaId(media));
73845
+ var $playBtn = null;
73846
+ if ($audioMedia) {
73847
+ $audioMedia.onloadstart = function () {
73848
+ console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has started loading data . . ."));
73849
+ };
73850
+ $audioMedia.onloadeddata = function () {
73851
+ if ($audioMedia.readyState >= 2) {
73852
+ console.debug("".concat(capitalizeStr(media.mediaType), " data for media > ").concat(media.id, " has been fully loaded . . ."));
73853
+ }
73854
+ };
73855
+ $audioMedia.oncanplay = function () {
73856
+ console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " can be played . . ."));
73857
+ };
73858
+ $audioMedia.onplaying = function () {
73859
+ console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " is now playing . . ."));
73860
+ if ($playBtn !== null) {
73861
+ $playBtn.remove();
73862
+ }
73863
+ };
73864
+ var audioPlayPromise = $audioMedia.play();
73865
+ if (audioPlayPromise !== undefined) {
73866
+ audioPlayPromise.then(function () {
73867
+ console.debug('autoplay started . . .');
73868
+ // Autoplay restarted
73869
+ })["catch"](function (error) {
73870
+ if (error.name === 'NotAllowedError') {
73871
+ var _$audioMedia$parentNo;
73872
+ // Let's show a play audio button
73873
+ $playBtn = document.createElement('button');
73874
+ $playBtn.classList.add('play-audio-btn');
73875
+ $playBtn.textContent = 'Play Audio';
73876
+ $playBtn.addEventListener('click', function () {
73877
+ $audioMedia.muted = false;
73878
+ $audioMedia.play();
73879
+ });
73880
+ (_$audioMedia$parentNo = $audioMedia.parentNode) === null || _$audioMedia$parentNo === void 0 || _$audioMedia$parentNo.insertBefore($playBtn, $audioMedia.nextSibling);
73881
+ }
73882
+ });
73883
+ }
73884
+ if (media.duration === 0) {
73885
+ $audioMedia.ondurationchange = function () {
73886
+ console.debug('Showing Media ' + media.id + ' for ' + $audioMedia.duration + 's of Region ' + media.region.regionId);
73887
+ };
73888
+ $audioMedia.onended = function () {
73889
+ var _media$emitter;
73890
+ console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has ended playing . . ."));
73891
+ (_media$emitter = media.emitter) === null || _media$emitter === void 0 || _media$emitter.emit('end', media);
73892
+ };
73893
+ }
73894
+ }
73895
+ }
73896
+ };
73897
+ return audioMediaObject;
73898
+ }
73899
+
73900
+ var Media = /*#__PURE__*/function () {
73901
+ function Media(region, mediaId, xml, options, xlr) {
73902
+ var _this$xml,
73903
+ _this$xml2,
73904
+ _this$xml3,
73905
+ _this$xml4,
73906
+ _this$xml5,
73907
+ _this = this;
73908
+ _classCallCheck(this, Media);
73909
+ _defineProperty(this, "attachedAudio", false);
73910
+ _defineProperty(this, "checkIframeStatus", false);
73911
+ _defineProperty(this, "containerName", '');
73912
+ _defineProperty(this, "divHeight", 0);
73913
+ _defineProperty(this, "divWidth", 0);
73914
+ _defineProperty(this, "duration", 0);
73915
+ _defineProperty(this, "emitter", createNanoEvents());
73365
73916
  _defineProperty(this, "enableStat", false);
73366
73917
  _defineProperty(this, "fileId", '');
73367
73918
  _defineProperty(this, "finished", false);
@@ -73512,12 +74063,18 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
73512
74063
  value: function startMediaTimer(media) {
73513
74064
  var _this2 = this;
73514
74065
  var preloadTimeMs = 2000;
73515
- var preloadTimeBufferMs = media.duration * 1000 - preloadTimeMs;
74066
+ var preloadTimeBufferMs = media.duration * 1000 / 2 - preloadTimeMs;
73516
74067
  var isPreparingNextMedia = false;
73517
74068
  if (preloadTimeBufferMs < preloadTimeMs) {
73518
74069
  // Use media duration when preloadTimeBufferMs is less than the preloadTimeMs
73519
- preloadTimeBufferMs = media.duration * 1000;
74070
+ preloadTimeBufferMs = media.duration / 2 * 1000;
73520
74071
  }
74072
+ console.debug('<><> XLR.debug >> [Media::startMediaTimer]', {
74073
+ preloadTimeMs: preloadTimeMs,
74074
+ preloadTimeBufferMs: preloadTimeBufferMs,
74075
+ isPreparingNextMedia: isPreparingNextMedia,
74076
+ mediaDuration: media.duration
74077
+ });
73521
74078
  this.mediaTimer = setInterval(function () {
73522
74079
  _this2.mediaTimeCount++;
73523
74080
  var elapsedTimeMs = _this2.mediaTimeCount * 1000;
@@ -73590,7 +74147,8 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
73590
74147
  scaleFactor: this.region.layout.scaleFactor,
73591
74148
  uri: this.uri,
73592
74149
  isGlobalContent: this.mediaType === 'global',
73593
- isImageOrVideo: this.mediaType === 'image' || this.mediaType === 'video'
74150
+ isImageOrVideo: this.mediaType === 'image' || this.mediaType === 'video',
74151
+ render: this.render
73594
74152
  });
73595
74153
  if (this.mediaType === 'image' || this.mediaType === 'video') {
73596
74154
  resourceUrlParams.mediaType = this.mediaType;
@@ -73603,861 +74161,213 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
73603
74161
  if (this.mediaType === 'image' || this.mediaType === 'video' || this.mediaType === 'audio') {
73604
74162
  tmpUrl = composeMediaUrl(resourceUrlParams);
73605
74163
  // this is an SSP Layout
73606
- if (this.region.layout.layoutId === -1) {
73607
- tmpUrl = this.uri;
73608
- }
73609
- }
73610
- }
73611
- this.url = tmpUrl;
73612
- // Loop if media has loop, or if region has loop and a single media
73613
- this.loop = this.options['loop'] == '1' || this.region.options['loop'] == '1' && this.region.totalMediaObjects == 1;
73614
- this.html = createMediaElement(this);
73615
- }
73616
- }, {
73617
- key: "run",
73618
- value: function run() {
73619
- var _this3 = this;
73620
- var transInDuration = 1;
73621
- var transInDirection = 'E';
73622
- if (Boolean(this.options['transinduration'])) {
73623
- transInDuration = Number(this.options.transinduration);
73624
- }
73625
- if (Boolean(this.options['transindirection'])) {
73626
- transInDirection = this.options.transindirection;
73627
- }
73628
- var defaultTransInOptions = {
73629
- duration: transInDuration
73630
- };
73631
- var transIn = transitionElement('defaultIn', {
73632
- duration: defaultTransInOptions.duration
73633
- });
73634
- if (Boolean(this.options['transin'])) {
73635
- var transInName = this.options['transin'];
73636
- if (transInName === 'fly') {
73637
- transInName = "".concat(transInName, "In");
73638
- defaultTransInOptions.keyframes = flyTransitionKeyframes({
73639
- trans: 'in',
73640
- direction: transInDirection,
73641
- height: this.divHeight,
73642
- width: this.divWidth
73643
- });
73644
- }
73645
- transIn = transitionElement(transInName, defaultTransInOptions);
73646
- }
73647
- var showCurrentMedia = function showCurrentMedia() {
73648
- var mediaId = getMediaId({
73649
- mediaType: _this3.mediaType,
73650
- containerName: _this3.containerName
73651
- });
73652
- var $region = document.querySelector('#' + _this3.region.containerName);
73653
- var $media = $region !== null && $region.querySelector('.' + mediaId);
73654
- if (!$media) {
73655
- $media = getNewMedia();
73656
- }
73657
- console.debug('??? XLR.debug >> Media run - show current media:', {
73658
- inDOM: document.body.contains($media),
73659
- mediaId: mediaId,
73660
- $media: $media,
73661
- mediaObject: _this3
73662
- });
73663
- if ($media) {
73664
- if (_this3.mediaType === 'video') {
73665
- var _this3$player, _this3$player2, _this3$player3, _this3$player4;
73666
- console.debug('??? XLR.debug >> Media.run() > showCurrentMedia() - Video media::START', {
73667
- mediaPlayer: _this3.player,
73668
- isDisposed: (_this3$player = _this3.player) === null || _this3$player === void 0 ? void 0 : _this3$player.isDisposed(),
73669
- el: (_this3$player2 = _this3.player) === null || _this3$player2 === void 0 ? void 0 : _this3$player2.el_
73670
- });
73671
- // Make sure that vjs is available on the media
73672
- // Else, re-initialize
73673
- if (_this3.player !== undefined) {
73674
- var existingPlayer = videojs(mediaId);
73675
- if (existingPlayer) {
73676
- _this3.player = existingPlayer;
73677
- } else {
73678
- if (_this3.player.isDisposed_) {
73679
- _this3.player = undefined;
73680
- _this3.player = videojs(mediaId, _objectSpread2({}, vjsDefaultOptions({
73681
- errorDisplay: _this3.xlr.config.platform !== exports.ConsumerPlatform.CHROMEOS,
73682
- loop: _this3.loop
73683
- })));
73684
- }
73685
- }
73686
- }
73687
- console.debug('??? XLR.debug >> Media.run() > showCurrentMedia() - Video media::END', {
73688
- mediaPlayer: _this3.player,
73689
- isDisposed: (_this3$player3 = _this3.player) === null || _this3$player3 === void 0 ? void 0 : _this3$player3.isDisposed(),
73690
- el: (_this3$player4 = _this3.player) === null || _this3$player4 === void 0 ? void 0 : _this3$player4.el_
73691
- });
73692
- if (_this3.player !== undefined && _this3.player.el_ !== null) {
73693
- _this3.player.el().style.setProperty('visibility', 'visible');
73694
- _this3.player.el().style.setProperty('z-index', '10');
73695
- _this3.player.el().style.setProperty('opacity', '1');
73696
- }
73697
- } else {
73698
- console.debug('??? XLR.debug >> Media::run() > showCurrentMedia', {
73699
- mediaType: _this3.mediaType,
73700
- render: _this3.render,
73701
- $media: $media,
73702
- state: _this3.state
73703
- });
73704
- $media.style.setProperty('visibility', 'visible');
73705
- $media.style.setProperty('z-index', '10');
73706
- $media.style.setProperty('opacity', '1');
73707
- }
73708
- if (Boolean(_this3.options['transin'])) {
73709
- $media.animate(transIn.keyframes, transIn.timing);
73710
- }
73711
- if (!_this3.region.layout.isOverlay || _this3.region.layout.isOverlay && _this3.region.totalMediaObjects > 1) {
73712
- _this3.emitter.emit('start', _this3);
73713
- }
73714
- }
73715
- };
73716
- var getNewMedia = function getNewMedia() {
73717
- var $region = document.getElementById("".concat(_this3.region.containerName));
73718
- // This function is for checking whether
73719
- // the region still has to show a media item
73720
- // when another region is not finished yet
73721
- if (_this3.region.complete && !_this3.region.layout.allEnded) {
73722
- // Add currentMedia to the region
73723
- $region && $region.insertBefore(_this3.html, $region.lastElementChild);
73724
- return _this3.html;
73725
- }
73726
- return null;
73727
- };
73728
- showCurrentMedia();
73729
- }
73730
- }, {
73731
- key: "stop",
73732
- value: function () {
73733
- var _stop = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
73734
- var $media;
73735
- return _regeneratorRuntime().wrap(function _callee$(_context) {
73736
- while (1) switch (_context.prev = _context.next) {
73737
- case 0:
73738
- $media = document.getElementById(getMediaId({
73739
- mediaType: this.mediaType,
73740
- containerName: this.containerName
73741
- }));
73742
- if ($media) {
73743
- $media.style.display = 'none';
73744
- $media.remove();
73745
- }
73746
- // Release blob URLs for image media to prevent memory leaks on long-running signage
73747
- if (this.mediaType === 'image' && this.url) {
73748
- BlobLoader.release(this.url);
73749
- }
73750
- case 3:
73751
- case "end":
73752
- return _context.stop();
73753
- }
73754
- }, _callee, this);
73755
- }));
73756
- function stop() {
73757
- return _stop.apply(this, arguments);
73758
- }
73759
- return stop;
73760
- }()
73761
- /**
73762
- * Emits a command from the shell command widget.
73763
- *
73764
- * @param media
73765
- * @private
73766
- */
73767
- }, {
73768
- key: "emitCommand",
73769
- value: function emitCommand(media) {
73770
- if (media.mediaType !== 'shellcommand') {
73771
- return;
73772
- }
73773
- var options = media.options;
73774
- if (options.commandtype === 'storedCommand' && options.commandcode) {
73775
- console.debug('Media::Emitter > Shell Command - Calling commandCodeReceived event');
73776
- this.xlr.emitter.emit('commandCodeReceived', options.commandcode);
73777
- return;
73778
- }
73779
- var commandString = '';
73780
- if (options.useglobalcommand === '1') {
73781
- commandString = options.globalcommand || '';
73782
- } else {
73783
- // Use platform-specific command when available
73784
- if (this.xlr.config.platform === exports.ConsumerPlatform.CHROMEOS) {
73785
- commandString = options.chromeoscommand || '';
73786
- } else if (this.xlr.config.platform === exports.ConsumerPlatform.ANDROID) {
73787
- commandString = options.androidcommand || '';
73788
- } else if (this.xlr.config.platform === exports.ConsumerPlatform.LINUX) {
73789
- commandString = options.linuxcommand || '';
73790
- } else if (this.xlr.config.platform === exports.ConsumerPlatform.TIZEN) {
73791
- commandString = options.tizencommand || '';
73792
- } else if (this.xlr.config.platform === exports.ConsumerPlatform.WEBOS) {
73793
- commandString = options.weboscommand || '';
73794
- } else if (this.xlr.config.platform === exports.ConsumerPlatform.WINDOWS) {
73795
- commandString = options.windowscommand || '';
73796
- }
73797
- // Fall back to the global command if the platform-specific one
73798
- // is missing, not configured, or not supported yet
73799
- if (!commandString && options.globalcommand) {
73800
- commandString = options.globalcommand;
73801
- }
73802
- }
73803
- if (commandString) {
73804
- console.debug('Media::Emitter > Shell Command - Calling commandStringReceived event');
73805
- this.xlr.emitter.emit('commandStringReceived', commandString);
73806
- return;
73807
- }
73808
- }
73809
- }]);
73810
- }();
73811
-
73812
- function nextId(options) {
73813
- if (options.idCounter > 500) {
73814
- options.idCounter = 0;
73815
- }
73816
- options.idCounter = options.idCounter + 1;
73817
- return options.idCounter;
73818
- }
73819
- var getMediaId = function getMediaId(_ref) {
73820
- var mediaType = _ref.mediaType,
73821
- containerName = _ref.containerName;
73822
- var mediaId = containerName;
73823
- if (mediaType === 'video') {
73824
- mediaId = mediaId + '-vid';
73825
- } else if (mediaType === 'audio') {
73826
- mediaId = mediaId + '-aud';
73827
- }
73828
- return mediaId;
73829
- };
73830
- var capitalizeStr = function capitalizeStr(inputStr) {
73831
- if (inputStr === null) {
73832
- return '';
73833
- }
73834
- return String(inputStr).charAt(0).toUpperCase() + String(inputStr).substring(1);
73835
- };
73836
- function getDataBlob(_x, _x2) {
73837
- return _getDataBlob.apply(this, arguments);
73838
- }
73839
- function _getDataBlob() {
73840
- _getDataBlob = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(src, jwtToken) {
73841
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
73842
- while (1) switch (_context3.prev = _context3.next) {
73843
- case 0:
73844
- return _context3.abrupt("return", fetch(src, {
73845
- method: 'GET',
73846
- headers: {
73847
- 'X-PREVIEW-JWT': jwtToken || ''
73848
- }
73849
- }).then(function (res) {
73850
- return res.blob();
73851
- }).then(function (blob) {
73852
- return new Promise(function (res, rej) {
73853
- var reader = new FileReader();
73854
- reader.onloadend = function () {
73855
- return res(reader.result);
73856
- };
73857
- reader.onerror = rej;
73858
- reader.readAsDataURL(blob);
73859
- });
73860
- }));
73861
- case 1:
73862
- case "end":
73863
- return _context3.stop();
73864
- }
73865
- }, _callee3);
73866
- }));
73867
- return _getDataBlob.apply(this, arguments);
73868
- }
73869
- function preloadMediaBlob(_x3, _x4, _x5) {
73870
- return _preloadMediaBlob.apply(this, arguments);
73871
- }
73872
- function _preloadMediaBlob() {
73873
- _preloadMediaBlob = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(src, type, jwtToken) {
73874
- var res, blob, data;
73875
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
73876
- while (1) switch (_context4.prev = _context4.next) {
73877
- case 0:
73878
- _context4.next = 2;
73879
- return fetch(src, {
73880
- method: 'GET',
73881
- headers: {
73882
- 'X-PREVIEW-JWT': jwtToken || ''
73883
- }
73884
- });
73885
- case 2:
73886
- res = _context4.sent;
73887
- blob = new Blob();
73888
- if (!(type === 'image')) {
73889
- _context4.next = 8;
73890
- break;
73891
- }
73892
- blob = new Blob();
73893
- _context4.next = 19;
73894
- break;
73895
- case 8:
73896
- if (!(type === 'video')) {
73897
- _context4.next = 14;
73898
- break;
73899
- }
73900
- _context4.next = 11;
73901
- return res.blob();
73902
- case 11:
73903
- blob = _context4.sent;
73904
- _context4.next = 19;
73905
- break;
73906
- case 14:
73907
- if (!(type === 'audio')) {
73908
- _context4.next = 19;
73909
- break;
73910
- }
73911
- _context4.next = 17;
73912
- return res.arrayBuffer();
73913
- case 17:
73914
- data = _context4.sent;
73915
- blob = new Blob([data], {
73916
- type: audioFileType(getFileExt(src))
73917
- });
73918
- case 19:
73919
- return _context4.abrupt("return", URL.createObjectURL(blob));
73920
- case 20:
73921
- case "end":
73922
- return _context4.stop();
73923
- }
73924
- }, _callee4);
73925
- }));
73926
- return _preloadMediaBlob.apply(this, arguments);
73927
- }
73928
- function fetchJSON(_x6, _x7) {
73929
- return _fetchJSON.apply(this, arguments);
73930
- }
73931
- function _fetchJSON() {
73932
- _fetchJSON = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(url, jwtToken) {
73933
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
73934
- while (1) switch (_context5.prev = _context5.next) {
73935
- case 0:
73936
- return _context5.abrupt("return", fetch(url, {
73937
- method: 'GET',
73938
- headers: {
73939
- 'X-PREVIEW-JWT': jwtToken || ''
73940
- }
73941
- }).then(function (res) {
73942
- return res.json();
73943
- })["catch"](function (err) {
73944
- console.debug(err);
73945
- }));
73946
- case 1:
73947
- case "end":
73948
- return _context5.stop();
73949
- }
73950
- }, _callee5);
73951
- }));
73952
- return _fetchJSON.apply(this, arguments);
73953
- }
73954
- function fetchText(_x8, _x9) {
73955
- return _fetchText.apply(this, arguments);
73956
- }
73957
- function _fetchText() {
73958
- _fetchText = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(url, jwtToken) {
73959
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
73960
- while (1) switch (_context6.prev = _context6.next) {
73961
- case 0:
73962
- return _context6.abrupt("return", fetch(url, {
73963
- method: 'GET',
73964
- headers: {
73965
- 'X-PREVIEW-JWT': jwtToken || ''
73966
- }
73967
- }).then(function (res) {
73968
- return res.text();
73969
- }).then(function (responseText) {
73970
- if (String(responseText).length > 0) {
73971
- return responseText;
73972
- } else {
73973
- return '';
73974
- }
73975
- })["catch"](function (err) {
73976
- console.debug(err);
73977
- return err === null || err === void 0 ? void 0 : err.message;
73978
- }));
73979
- case 1:
73980
- case "end":
73981
- return _context6.stop();
73982
- }
73983
- }, _callee6);
73984
- }));
73985
- return _fetchText.apply(this, arguments);
73986
- }
73987
- function getFileExt(filename) {
73988
- var filenameArr = String(filename).split('.');
73989
- return filenameArr[filenameArr.length - 1];
73990
- }
73991
- function audioFileType(str) {
73992
- var validAudioTypes = {
73993
- 'mp3': 'audio/mp3',
73994
- 'wav': 'audio/wav',
73995
- 'ogg': 'audio/ogg'
73996
- };
73997
- if (Boolean(validAudioTypes[str])) {
73998
- return validAudioTypes[str];
73999
- }
74000
- return undefined;
74001
- }
74002
- function videoFileType(str) {
74003
- var validVideoTypes = {
74004
- 'mp4': 'video/mp4',
74005
- 'webm': 'video/webm',
74006
- 'wmv': 'video/x-ms-wmv'
74007
- };
74008
- if (Boolean(validVideoTypes[str])) {
74009
- return validVideoTypes[str];
74010
- }
74011
- return undefined;
74012
- }
74013
- function composeResourceUrlByPlatform(options, params) {
74014
- var resourceUrl = params.regionOptions.getResourceUrl.replace(":regionId", params.regionId).replace(":id", params.mediaId) + '?preview=1&layoutPreview=1';
74015
- if (options.platform === 'CMS') {
74016
- resourceUrl += '&jwt=' + params.regionOptions.previewJwt;
74017
- }
74018
- if (options.platform === 'chromeOS') {
74019
- var resourceEndpoint = '/required-files/resource/';
74020
- if (!params.isGlobalContent && params.isImageOrVideo) {
74021
- resourceUrl = resourceEndpoint + params.fileId + '?saveAs=' + params.uri;
74022
- }
74023
- } else if (!Boolean(params['mediaType'])) {
74024
- resourceUrl += '&scale_override=' + params.scaleFactor;
74025
- }
74026
- return resourceUrl;
74027
- }
74028
- function composeResourceUrl(options, params) {
74029
- var _options$config, _options$config2, _options$config3;
74030
- var schemaVersion = options && ((_options$config = options.config) === null || _options$config === void 0 ? void 0 : _options$config.schemaVersion);
74031
- var hardwareKey = options && ((_options$config2 = options.config) === null || _options$config2 === void 0 ? void 0 : _options$config2.hardwareKey);
74032
- var serverKey = options && ((_options$config3 = options.config) === null || _options$config3 === void 0 ? void 0 : _options$config3.cmsKey);
74033
- return '/pwa/getResource' + '?v=' + schemaVersion + '&serverKey=' + serverKey + '&hardwareKey=' + hardwareKey + '&layoutId=' + params.layoutId + '&regionId=' + params.regionId + '&mediaId=' + params.mediaId;
74034
- }
74035
- function composeMediaUrl(params) {
74036
- return '/xmds.php?file=' + params.uri;
74037
- }
74038
- function composeBgUrlByPlatform(platform, params) {
74039
- var bgImageUrl = '';
74040
- if (platform === 'CMS') {
74041
- bgImageUrl = params.layoutBackgroundDownloadUrl.replace(":id", params.layout.id) + '&preview=1&width=' + params.layout.sWidth + '&height=' + params.layout.sHeight + '&dynamic&proportional=0';
74042
- } else if (platform === 'chromeOS') {
74043
- bgImageUrl = composeMediaUrl({
74044
- uri: params.layout.bgImage
74045
- });
74046
- }
74047
- // @TODO: Add condition to handle electron platform
74048
- return bgImageUrl;
74049
- }
74050
- function getIndexByLayoutId(layoutsInput, layoutId) {
74051
- var layoutIndexes = layoutsInput.reduce(function (a, b, indx) {
74052
- a[Number(b.layoutId)] = _objectSpread2(_objectSpread2({}, b), {}, {
74053
- index: indx
74054
- });
74055
- return a;
74056
- }, {});
74057
- if (layoutId === null || !layoutId) {
74058
- return layoutIndexes;
74059
- }
74060
- if (Boolean(layoutIndexes[layoutId])) {
74061
- return layoutIndexes[layoutId];
74062
- }
74063
- // Defaults to 0
74064
- return {
74065
- index: 0
74066
- };
74067
- }
74068
- function isEmpty(input) {
74069
- return !Boolean(input) || String(input).length === 0;
74070
- }
74071
- function getAllAttributes(elem) {
74072
- if (!elem || elem === null) {
74073
- return {};
74074
- }
74075
- return elem.getAttributeNames().reduce(function (obj, name) {
74076
- return _objectSpread2(_objectSpread2({}, obj), {}, _defineProperty({}, name, {
74077
- value: elem.getAttribute(name)
74078
- }));
74079
- }, {});
74080
- }
74081
- /**
74082
- * Create expiration day based on current date
74083
- * @param numDays Number of days as expiry
74084
- * @returns JSON string format of date
74085
- */
74086
- function setExpiry(numDays) {
74087
- var today = new Date();
74088
- return new Date(today.setHours(24 * numDays || 1)).toJSON();
74089
- }
74090
- /**
74091
- * Check if given layout exists in the loop using layoutId
74092
- * @param layouts Schedule loop unique layouts (uniqueLayouts)
74093
- * @param layoutId Layout ID of the layout to look for
74094
- *
74095
- * @return boolean
74096
- */
74097
- function isLayoutValid(layouts, layoutId) {
74098
- if (layouts.length < 1 || !layoutId) {
74099
- return false;
74100
- }
74101
- var layoutIndex = layouts.findIndex(function (l) {
74102
- return l.layoutId === layoutId;
74103
- });
74104
- return layoutIndex !== -1;
74105
- }
74106
- function getLayoutIndexByLayoutId(layouts, layoutId) {
74107
- if (layouts.length < 1 || !layoutId) {
74108
- return null;
74109
- }
74110
- return layouts.findIndex(function (l) {
74111
- return l.layoutId === layoutId;
74112
- });
74113
- }
74114
- function hasDefaultOnly(inputLayouts) {
74115
- var _inputLayouts$0$respo;
74116
- if (!inputLayouts) {
74117
- return false;
74118
- }
74119
- return inputLayouts.length === 1 && ((_inputLayouts$0$respo = inputLayouts[0].response) === null || _inputLayouts$0$respo === void 0 ? void 0 : _inputLayouts$0$respo.nodeName) === 'default';
74120
- }
74121
- function hasSspLayout(inputLayouts) {
74122
- var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
74123
- if (!inputLayouts || inputLayouts.length === 0) {
74124
- return defaultValue;
74125
- }
74126
- return inputLayouts.find(function (layout) {
74127
- return layout.layoutId === -1;
74128
- }) !== undefined;
74129
- }
74130
- function prepareIframe(media) {
74131
- var iframe = document.createElement('iframe');
74132
- iframe.scrolling = 'no';
74133
- iframe.id = media.iframeName;
74134
- iframe.width = "".concat(media.divWidth, "px");
74135
- iframe.height = "".concat(media.divHeight, "px");
74136
- iframe.style.cssText = "border: 0;";
74137
- if ((media.render === 'html' || media.render === 'webpage') && media.url !== null) {
74138
- iframe.src = media.url;
74139
- } else {
74140
- iframe.src = "".concat(media.url, "&width=").concat(media.divWidth, "&height=").concat(media.divHeight);
74141
- }
74142
- return iframe;
74143
- }
74144
- function prepareImage(media, container) {
74145
- if (media.options['scaletype'] === 'stretch') {
74146
- container.style.cssText = container.style.cssText.concat("background-size: 100% 100%;");
74147
- } else if (media.options['scaletype'] === 'fit') {
74148
- container.style.cssText = container.style.cssText.concat("background-size: cover;");
74149
- } else {
74150
- // Center scale type, do we have align or valign?
74151
- var align = media.options['align'] == "" ? "center" : media.options['align'];
74152
- var valign = media.options['valign'] == "" || media.options['valign'] == "middle" ? "center" : media.options['valign'];
74153
- container.style.cssText = container.style.cssText.concat("background-position: ".concat(align, " ").concat(valign));
74154
- }
74155
- return container;
74156
- }
74157
- function prepareVideo(media, container) {
74158
- var $videoMedia = composeVideoSource(container, media);
74159
- var isMuted = false;
74160
- if (Boolean(media.options['mute'])) {
74161
- isMuted = media.options.mute === '1';
74162
- }
74163
- if (Boolean(media.options['scaletype'])) {
74164
- if (media.options.scaletype === 'stretch') {
74165
- $videoMedia.style.objectFit = 'fill';
74166
- }
74167
- }
74168
- $videoMedia.classList.add('video-js', 'vjs-default-skin');
74169
- if (media.loop) {
74170
- media.loop = true;
74171
- $videoMedia.loop = true;
74172
- }
74173
- media.muted = isMuted;
74174
- return $videoMedia;
74175
- }
74176
- function prepareAudio(media, container) {
74177
- var $audioMedia = container;
74178
- $audioMedia.preload = 'auto';
74179
- $audioMedia.textContent = 'Unsupported Audio';
74180
- $audioMedia.autoplay = true;
74181
- if (media.loop) {
74182
- $audioMedia.loop = true;
74183
- }
74184
- return $audioMedia;
74185
- }
74186
- function createMediaElement(mediaObject) {
74187
- var self = mediaObject;
74188
- var mediaId = getMediaId(self);
74189
- var mediaSelector = ".media--item.".concat(mediaId);
74190
- var $media = self.region.html.querySelector(mediaSelector);
74191
- if ($media === null) {
74192
- if (self.mediaType === 'video') {
74193
- $media = document.createElement('video');
74194
- } else if (self.mediaType === 'audio') {
74195
- $media = new Audio();
74196
- } else {
74197
- $media = document.createElement('div');
74164
+ if (this.region.layout.layoutId === -1) {
74165
+ tmpUrl = this.uri;
74166
+ }
74167
+ }
74168
+ } else if (this.xlr.config.platform === exports.ConsumerPlatform.ELECTRON) {
74169
+ tmpUrl = composeResourceUrlByPlatform(this.xlr.config, resourceUrlParams);
74170
+ }
74171
+ this.url = tmpUrl;
74172
+ // Loop if media has loop, or if region has loop and a single media
74173
+ this.loop = this.options['loop'] == '1' || this.region.options['loop'] == '1' && this.region.totalMediaObjects == 1;
74174
+ this.html = createMediaElement(this);
74198
74175
  }
74199
- $media.id = mediaId;
74200
- }
74201
- $media.dataset.mediaId = self.id;
74202
- $media.dataset.mediaType = self.mediaType;
74203
- $media.dataset.type = self.type;
74204
- $media.dataset.render = self.render;
74205
- $media.dataset.duration = String(self.duration);
74206
- $media.dataset.fileId = self.fileId;
74207
- $media.className = "media--item ".concat(mediaId);
74208
- /* Scale the Content Container */
74209
- var cssText = "\n width: ".concat(self.divWidth, "px;\n height: ").concat(self.divHeight, "px;\n position: absolute;\n background-size: contain;\n background-repeat: no-repeat;\n background-position: center;\n ");
74210
- if (self.mediaType !== 'video') {
74211
- cssText += "\n visibility: hidden;\n opacity: 0;\n z-index: 0;\n ";
74212
- }
74213
- $media.style.cssText = cssText;
74214
- if (self.render === 'html' || self.mediaType === 'ticker' || self.mediaType === 'webpage') {
74215
- self.checkIframeStatus = true;
74216
- self.iframe = prepareIframe(self);
74217
- } else if (self.mediaType === "image") {
74218
- $media = prepareImage(self, $media);
74219
- } else if (self.mediaType === 'video') {
74220
- $media = prepareVideo(self, $media);
74221
- } else if (self.mediaType === 'audio') {
74222
- $media = prepareAudio(self, $media);
74223
- }
74224
- // Duration is per item condition
74225
- if ((self.render === 'html' || self.mediaType === 'ticker') && self.url !== null) {
74226
- /* Check if the ticker duration is based on the number of items in the feed */
74227
- if (self.options['durationisperitem'] === '1') {
74228
- var regex = new RegExp('<!-- NUMITEMS=(.*?) -->');
74229
- _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
74230
- var html, res;
74231
- return _regeneratorRuntime().wrap(function _callee$(_context) {
74232
- while (1) switch (_context.prev = _context.next) {
74233
- case 0:
74234
- _context.next = 2;
74235
- return fetchJSON("".concat(self.url, "&width=").concat(self.divWidth, "&height=").concat(self.divHeight), self.options.previewJwt);
74236
- case 2:
74237
- html = _context.sent;
74238
- console.debug({
74239
- html: html
74240
- });
74241
- res = regex.exec(html);
74242
- if (res !== null) {
74243
- self.duration = parseInt(String(self.duration)) * parseInt(res[1]);
74176
+ }, {
74177
+ key: "run",
74178
+ value: function run() {
74179
+ var _this3 = this;
74180
+ var transInDuration = 1;
74181
+ var transInDirection = 'E';
74182
+ if (Boolean(this.options['transinduration'])) {
74183
+ transInDuration = Number(this.options.transinduration);
74184
+ }
74185
+ if (Boolean(this.options['transindirection'])) {
74186
+ transInDirection = this.options.transindirection;
74187
+ }
74188
+ var defaultTransInOptions = {
74189
+ duration: transInDuration
74190
+ };
74191
+ var transIn = transitionElement('defaultIn', {
74192
+ duration: defaultTransInOptions.duration
74193
+ });
74194
+ if (Boolean(this.options['transin'])) {
74195
+ var transInName = this.options['transin'];
74196
+ if (transInName === 'fly') {
74197
+ transInName = "".concat(transInName, "In");
74198
+ defaultTransInOptions.keyframes = flyTransitionKeyframes({
74199
+ trans: 'in',
74200
+ direction: transInDirection,
74201
+ height: this.divHeight,
74202
+ width: this.divWidth
74203
+ });
74204
+ }
74205
+ transIn = transitionElement(transInName, defaultTransInOptions);
74206
+ }
74207
+ var showCurrentMedia = function showCurrentMedia() {
74208
+ var mediaId = getMediaId({
74209
+ mediaType: _this3.mediaType,
74210
+ containerName: _this3.containerName
74211
+ });
74212
+ var $region = document.querySelector('#' + _this3.region.containerName);
74213
+ var $media = $region !== null && $region.querySelector('.' + mediaId);
74214
+ if (!$media) {
74215
+ $media = getNewMedia();
74216
+ }
74217
+ console.debug('??? XLR.debug >> Media run - show current media:', {
74218
+ inDOM: document.body.contains($media),
74219
+ mediaId: mediaId,
74220
+ $media: $media,
74221
+ mediaObject: _this3
74222
+ });
74223
+ if ($media) {
74224
+ if (_this3.mediaType === 'video') {
74225
+ var _this3$player, _this3$player2, _this3$player3, _this3$player4;
74226
+ console.debug('??? XLR.debug >> Media.run() > showCurrentMedia() - Video media::START', {
74227
+ mediaPlayer: _this3.player,
74228
+ isDisposed: (_this3$player = _this3.player) === null || _this3$player === void 0 ? void 0 : _this3$player.isDisposed(),
74229
+ el: (_this3$player2 = _this3.player) === null || _this3$player2 === void 0 ? void 0 : _this3$player2.el_
74230
+ });
74231
+ // Make sure that vjs is available on the media
74232
+ // Else, re-initialize
74233
+ if (_this3.player !== undefined) {
74234
+ var existingPlayer = videojs(mediaId);
74235
+ if (existingPlayer) {
74236
+ _this3.player = existingPlayer;
74237
+ } else {
74238
+ if (_this3.player.isDisposed_) {
74239
+ _this3.player = undefined;
74240
+ _this3.player = videojs(mediaId, _objectSpread2({}, vjsDefaultOptions({
74241
+ errorDisplay: _this3.xlr.config.platform !== exports.ConsumerPlatform.CHROMEOS,
74242
+ loop: _this3.loop
74243
+ })));
74244
+ }
74244
74245
  }
74245
- case 6:
74246
- case "end":
74247
- return _context.stop();
74246
+ }
74247
+ console.debug('??? XLR.debug >> Media.run() > showCurrentMedia() - Video media::END', {
74248
+ mediaPlayer: _this3.player,
74249
+ isDisposed: (_this3$player3 = _this3.player) === null || _this3$player3 === void 0 ? void 0 : _this3$player3.isDisposed(),
74250
+ el: (_this3$player4 = _this3.player) === null || _this3$player4 === void 0 ? void 0 : _this3$player4.el_
74251
+ });
74252
+ if (_this3.player !== undefined && _this3.player.el_ !== null) {
74253
+ _this3.player.el().style.setProperty('visibility', 'visible');
74254
+ _this3.player.el().style.setProperty('z-index', '10');
74255
+ _this3.player.el().style.setProperty('opacity', '1');
74256
+ }
74257
+ } else {
74258
+ console.debug('??? XLR.debug >> Media::run() > showCurrentMedia', {
74259
+ mediaType: _this3.mediaType,
74260
+ render: _this3.render,
74261
+ $media: $media,
74262
+ state: _this3.state
74263
+ });
74264
+ $media.style.setProperty('visibility', 'visible');
74265
+ $media.style.setProperty('z-index', '10');
74266
+ $media.style.setProperty('opacity', '1');
74248
74267
  }
74249
- }, _callee);
74250
- }))();
74251
- }
74252
- }
74253
- // Check if the media has fade-in/out transitions
74254
- if (Boolean(self.options['transin']) && Boolean(self.options['transinduration'])) {
74255
- var transInDuration = Number(self.options.transinduration);
74256
- var fadeInTrans = transitionElement('fadeIn', {
74257
- duration: transInDuration
74258
- });
74259
- $media.animate(fadeInTrans.keyframes, fadeInTrans.timing);
74260
- }
74261
- // Add media to the region
74262
- // Second media if exists, will be off-canvas
74263
- // All added media will be hidden by default
74264
- // It will start showing when region.nextMedia() function is called
74265
- // When there's only 1 item and loop = false, don't remove the item but leave it at its last state
74266
- // For image, and only 1 item, it should still have the transition for next state
74267
- // Add conditions for video duration being 0 or 1 and also the loop property
74268
- // For video url, we have to create a URL out of the XLF video URL
74269
- /**
74270
- * @DONE
74271
- * Case 1: Video duration = 0, this will play the video for its entire duration
74272
- * Case 2: Video duration is set > 0 and loop = false
74273
- * E.g. Set duration = 100s, video duration = 62s
74274
- * the video will play until 62s and will stop to its last frame until 100s
74275
- * After 100s, it will expire
74276
- * Case 3: Video duration is set > 0 and loop = true
74277
- * E.g. Set duration = 100s, video duration = 62s, loop = true
74278
- * the video will play until 62s and will loop through until the remaining 38s
74279
- * to complete the 100s set duration
74280
- */
74281
- // Add html node to media for
74282
- // self.html = $media;
74283
- return $media;
74284
- }
74285
- function prepareVideoMedia(media, region) {
74286
- var mediaId = getMediaId(media);
74287
- // Check if html is ready and is in the DOM
74288
- if (media.html !== null) {
74289
- // Clean up video.js instance
74290
- var existingPlayer = videojs.getPlayer(mediaId);
74291
- if (existingPlayer !== undefined) {
74292
- existingPlayer.dispose();
74293
- media.player = undefined;
74294
- }
74295
- var $layout = region.layout.html;
74296
- var layoutSelector = '#' + region.layout.containerName + '[data-sequence="' + region.layout.index + '"]';
74297
- var $layoutWithIndex = document.querySelector(layoutSelector);
74298
- var $region = document.querySelector('#' + region.containerName);
74299
- var mediaInRegion = $region === null || $region === void 0 ? void 0 : $region.querySelector('.' + mediaId);
74300
- console.debug('??? XLR.debug >> [Generators::prepareVideoMedia]', {
74301
- layoutSelector: layoutSelector,
74302
- $layoutWithIndex: $layoutWithIndex,
74303
- $region: $region,
74304
- mediaInRegion: mediaInRegion,
74305
- mediaHtml: media.html,
74306
- existingPlayer: existingPlayer,
74307
- mediaId: mediaId,
74308
- layoutInDOM: document.body.contains($layout)
74309
- });
74310
- if (!mediaInRegion) {
74311
- media.html = createMediaElement(media);
74312
- } else {
74313
- mediaInRegion.remove();
74314
- media.html = createMediaElement(media);
74268
+ if (Boolean(_this3.options['transin'])) {
74269
+ $media.animate(transIn.keyframes, transIn.timing);
74270
+ }
74271
+ if (!_this3.region.layout.isOverlay || _this3.region.layout.isOverlay && _this3.region.totalMediaObjects > 1) {
74272
+ _this3.emitter.emit('start', _this3);
74273
+ }
74274
+ }
74275
+ };
74276
+ var getNewMedia = function getNewMedia() {
74277
+ var $region = document.getElementById("".concat(_this3.region.containerName));
74278
+ // This function is for checking whether
74279
+ // the region still has to show a media item
74280
+ // when another region is not finished yet
74281
+ if (_this3.region.complete && !_this3.region.layout.allEnded) {
74282
+ // Add currentMedia to the region
74283
+ $region && $region.insertBefore(_this3.html, $region.lastElementChild);
74284
+ return _this3.html;
74285
+ }
74286
+ return null;
74287
+ };
74288
+ showCurrentMedia();
74315
74289
  }
74316
- // Append fresh copy of the media into the region
74317
- $region !== null && $region.appendChild(media.html);
74318
- var isMediaInDOM = document.body.contains(media.html);
74319
- console.debug('??? XLR.debug >> [Generators::prepareVideoMedia]', {
74320
- isMediaInDOM: isMediaInDOM,
74321
- mediaHtml: media.html,
74322
- mediaId: mediaId
74323
- });
74324
- // Initialize video.js
74325
- media.player = videojs(mediaId, _objectSpread2(_objectSpread2({}, defaultVjsOpts), {}, {
74326
- errorDisplay: region.xlr.config.platform !== exports.ConsumerPlatform.CHROMEOS,
74327
- loop: media.loop
74328
- }));
74329
- media.player.on('error', /*#__PURE__*/function () {
74330
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(err) {
74331
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
74332
- while (1) switch (_context2.prev = _context2.next) {
74290
+ }, {
74291
+ key: "stop",
74292
+ value: function () {
74293
+ var _stop = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
74294
+ var $media;
74295
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
74296
+ while (1) switch (_context.prev = _context.next) {
74333
74297
  case 0:
74334
- if (media.region.xlr.config.platform === exports.ConsumerPlatform.CHROMEOS) {
74335
- playerReportFault('Video file not supported', media).then(function () {
74336
- media.emitter.emit('end', media);
74337
- });
74298
+ $media = document.getElementById(getMediaId({
74299
+ mediaType: this.mediaType,
74300
+ containerName: this.containerName
74301
+ }));
74302
+ if ($media) {
74303
+ $media.style.display = 'none';
74304
+ $media.remove();
74338
74305
  }
74339
- case 1:
74306
+ // Release blob URLs for image media to prevent memory leaks on long-running signage
74307
+ if (this.mediaType === 'image' && this.url) {
74308
+ BlobLoader.release(this.url);
74309
+ }
74310
+ case 3:
74340
74311
  case "end":
74341
- return _context2.stop();
74312
+ return _context.stop();
74342
74313
  }
74343
- }, _callee2);
74314
+ }, _callee, this);
74344
74315
  }));
74345
- return function (_x10) {
74346
- return _ref3.apply(this, arguments);
74347
- };
74348
- }());
74349
- media.player.el().style.setProperty('visibility', 'hidden');
74350
- media.player.el().style.setProperty('opacity', '0');
74351
- media.player.el().style.setProperty('z-index', '-99');
74352
- }
74353
- }
74354
- function prepareImageMedia(media, region) {
74355
- var mediaId = getMediaId(media);
74356
- media.html.style.setProperty('background-image', "url(".concat(media.url));
74357
- // Check if media in region
74358
- // Remove old copy before inserting fresh copy
74359
- var mediaInRegion = region.html.querySelector('.' + mediaId);
74360
- if (mediaInRegion) {
74361
- mediaInRegion.remove();
74362
- }
74363
- // Append media to its region
74364
- var $region = document.querySelector('#' + region.containerName);
74365
- $region !== null && $region.appendChild(media.html);
74366
- }
74367
- function prepareAudioMedia(media, region) {
74368
- var mediaId = getMediaId(media);
74369
- if (media.url !== null) {
74370
- media.html.src = media.url;
74371
- }
74372
- // Check if media in region
74373
- // Remove old copy before inserting fresh copy of the media
74374
- var mediaInRegion = region.html.querySelector('.' + mediaId);
74375
- if (mediaInRegion) {
74376
- mediaInRegion.remove();
74377
- }
74378
- // Append media to its region
74379
- var $region = document.querySelector('#' + region.containerName);
74380
- $region !== null && $region.appendChild(media.html);
74381
- }
74382
- function prepareHtmlMedia(media, region) {
74383
- // Set state as false ( for now )
74384
- media.ready = false;
74385
- if (media.html) {
74386
- var mediaId = getMediaId(media);
74387
- // Clean up old copy of the media
74388
- // before inserting fresh copy
74389
- var mediaInRegion = region.html.querySelector('.' + mediaId);
74390
- // Append iframe
74391
- media.html.innerHTML = '';
74392
- media.html.appendChild(media.iframe);
74393
- if (!mediaInRegion) {
74394
- // Add fresh copy of the media into the region
74395
- var $region = document.querySelector('#' + region.containerName);
74396
- $region !== null && $region.appendChild(media.html);
74397
- media.ready = true;
74398
- }
74399
- }
74400
- }
74401
- function playerReportFault(_x11, _x12) {
74402
- return _playerReportFault.apply(this, arguments);
74403
- }
74404
- function _playerReportFault() {
74405
- _playerReportFault = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(msg, media) {
74406
- var playerSW, hasSW;
74407
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
74408
- while (1) switch (_context7.prev = _context7.next) {
74409
- case 0:
74410
- // Immediately expire media and report a fault
74411
- playerSW = PwaSW();
74412
- _context7.next = 3;
74413
- return playerSW.getSW();
74414
- case 3:
74415
- hasSW = _context7.sent;
74416
- if (hasSW) {
74417
- playerSW.postMsg({
74418
- type: 'MEDIA_FAULT',
74419
- code: 5002,
74420
- reason: msg,
74421
- mediaId: media.id,
74422
- regionId: media.region.id,
74423
- layoutId: media.region.layout.id,
74424
- date: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
74425
- // Temporary setting
74426
- expires: format(new Date(setExpiry(1)), 'yyyy-MM-dd HH:mm:ss')
74427
- }).then(function () {
74428
- // We try to prepare next media if we have more than 1 media
74429
- if (media.region.totalMediaObjects > 1) {
74430
- media.region.prepareNextMedia();
74431
- }
74432
- })["finally"](function () {
74433
- // Stopping media as we have reported the error as fault
74434
- console.debug('??? XLR.debug >> VideoMedia - Done reporting media fault', {
74435
- mediaId: media.id,
74436
- regionItems: media.region.totalMediaObjects
74437
- });
74438
- });
74439
- }
74440
- case 5:
74441
- case "end":
74442
- return _context7.stop();
74316
+ function stop() {
74317
+ return _stop.apply(this, arguments);
74443
74318
  }
74444
- }, _callee7);
74445
- }));
74446
- return _playerReportFault.apply(this, arguments);
74447
- }
74448
-
74449
- const urlAlphabet =
74450
- 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
74451
-
74452
- /* @ts-self-types="./index.d.ts" */
74453
- let nanoid = (size = 21) => {
74454
- let id = '';
74455
- let bytes = crypto.getRandomValues(new Uint8Array((size |= 0)));
74456
- while (size--) {
74457
- id += urlAlphabet[bytes[size] & 63];
74458
- }
74459
- return id
74460
- };
74319
+ return stop;
74320
+ }()
74321
+ /**
74322
+ * Emits a command from the shell command widget.
74323
+ *
74324
+ * @param media
74325
+ * @private
74326
+ */
74327
+ }, {
74328
+ key: "emitCommand",
74329
+ value: function emitCommand(media) {
74330
+ if (media.mediaType !== 'shellcommand') {
74331
+ return;
74332
+ }
74333
+ var options = media.options;
74334
+ if (options.commandtype === 'storedCommand' && options.commandcode) {
74335
+ console.debug('Media::Emitter > Shell Command - Calling commandCodeReceived event');
74336
+ this.xlr.emitter.emit('commandCodeReceived', options.commandcode);
74337
+ return;
74338
+ }
74339
+ var commandString = '';
74340
+ if (options.useglobalcommand === '1') {
74341
+ commandString = options.globalcommand || '';
74342
+ } else {
74343
+ // Use platform-specific command when available
74344
+ if (this.xlr.config.platform === exports.ConsumerPlatform.CHROMEOS) {
74345
+ commandString = options.chromeoscommand || '';
74346
+ } else if (this.xlr.config.platform === exports.ConsumerPlatform.ANDROID) {
74347
+ commandString = options.androidcommand || '';
74348
+ } else if (this.xlr.config.platform === exports.ConsumerPlatform.LINUX) {
74349
+ commandString = options.linuxcommand || '';
74350
+ } else if (this.xlr.config.platform === exports.ConsumerPlatform.TIZEN) {
74351
+ commandString = options.tizencommand || '';
74352
+ } else if (this.xlr.config.platform === exports.ConsumerPlatform.WEBOS) {
74353
+ commandString = options.weboscommand || '';
74354
+ } else if (this.xlr.config.platform === exports.ConsumerPlatform.WINDOWS) {
74355
+ commandString = options.windowscommand || '';
74356
+ }
74357
+ // Fall back to the global command if the platform-specific one
74358
+ // is missing, not configured, or not supported yet
74359
+ if (!commandString && options.globalcommand) {
74360
+ commandString = options.globalcommand;
74361
+ }
74362
+ }
74363
+ if (commandString) {
74364
+ console.debug('Media::Emitter > Shell Command - Calling commandStringReceived event');
74365
+ this.xlr.emitter.emit('commandStringReceived', commandString);
74366
+ return;
74367
+ }
74368
+ }
74369
+ }]);
74370
+ }();
74461
74371
 
74462
74372
  var Region = /*#__PURE__*/function () {
74463
74373
  // ===== Constructor =====
@@ -74615,10 +74525,6 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
74615
74525
  });
74616
74526
  // Prepare first media
74617
74527
  if (this.mediaObjects.length > 0) {
74618
- // Clean up region first
74619
- // if (this.html?.children.length > 0) {
74620
- // this.html.innerHTML = '';
74621
- // }
74622
74528
  this.prepareFirstMedia();
74623
74529
  }
74624
74530
  }
@@ -74651,6 +74557,11 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
74651
74557
  value: function prepareNextMedia() {
74652
74558
  var nextMediaIndex = (this.currentMediaIndex + 1) % this.totalMediaObjects;
74653
74559
  var nextMedia = this.mediaObjects[nextMediaIndex];
74560
+ console.debug('<><> XLR.debug >> [Media] - [Region::prepareNextMedia()] - Preparing next media', {
74561
+ currentMediaIndex: this.currentMediaIndex,
74562
+ nextMediaIndex: nextMediaIndex,
74563
+ nextMediaId: nextMedia.mediaId
74564
+ });
74654
74565
  this.prepareMedia(nextMedia);
74655
74566
  }
74656
74567
  }, {
@@ -74669,36 +74580,6 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
74669
74580
  regionId: this.id,
74670
74581
  oldMedia: (_this$oldMedia = this.oldMedia) === null || _this$oldMedia === void 0 ? void 0 : _this$oldMedia.containerName
74671
74582
  });
74672
- // const $region = document.getElementById(`${this.containerName}`);
74673
- // Preload first item
74674
- // if (this.currentMediaIndex > 0 && this.nxtMedia) {
74675
- // // Prepare next items
74676
- // this.prepareMedia(this.nxtMedia);
74677
- // } else {
74678
- // this.prepareMedia(this.currMedia);
74679
- // }
74680
- // Append available media to region DOM
74681
- // if (this.currMedia) {
74682
- //
74683
- // this.currEl = createMediaElement(this.currMedia);
74684
- // this.currMedia.html = this.currEl;
74685
- //
74686
- // console.debug('<> XLR.debug prepareMediaObjects::currMedia', {
74687
- // currentMedia: this.currMedia.containerName,
74688
- // regionId: this.id,
74689
- // });
74690
- // ($region) && $region.insertBefore(this.currEl as Node, $region.lastElementChild);
74691
- // }
74692
- // if (this.totalMediaObjects > 1 && this.nxtMedia) {
74693
- // this.nxtEl = createMediaElement(this.nxtMedia);
74694
- // this.nxtMedia.html = this.nxtEl;
74695
- //
74696
- // console.debug('<> XLR.debug prepareMediaObjects::nxtMedia', {
74697
- // nextMedia: this.nxtMedia.containerName,
74698
- // regionId: this.id,
74699
- // });
74700
- // ($region) && $region.insertBefore(this.nxtEl as Node, $region.lastElementChild);
74701
- // }
74702
74583
  }
74703
74584
  }
74704
74585
  }, {
@@ -74712,116 +74593,6 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
74712
74593
  this.layout.regions[this.index] = this;
74713
74594
  this.layout.regionExpired();
74714
74595
  }
74715
- }, {
74716
- key: "prepareVideo",
74717
- value: function () {
74718
- var _prepareVideo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(media, container) {
74719
- var _this2 = this;
74720
- var video;
74721
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
74722
- while (1) switch (_context2.prev = _context2.next) {
74723
- case 0:
74724
- video = media.html;
74725
- if (media.url !== null) {
74726
- video.src = media.url;
74727
- }
74728
- container !== null && container.appendChild(media.html);
74729
- return _context2.abrupt("return", new Promise(function (resolve) {
74730
- var _media$videoHandler$p;
74731
- var vidType = videoFileType(getFileExt(media.uri));
74732
- // Initialize Video.js
74733
- media.player = videojs(video, _objectSpread2(_objectSpread2({}, defaultVjsOpts), {}, {
74734
- errorDisplay: _this2.xlr.config.platform !== exports.ConsumerPlatform.CHROMEOS,
74735
- loop: media.loop,
74736
- sources: [{
74737
- src: media.url,
74738
- type: vidType
74739
- }] // Adjust MIME type if dynamic
74740
- }));
74741
- media.player.el().style.setProperty('visibility', 'hidden');
74742
- media.player.el().style.setProperty('z-index', '0');
74743
- media.player.el().style.setProperty('opacity', '0');
74744
- // Register video handler
74745
- media.videoHandler = videoMediaHandler(media, _this2.xlr.config.platform);
74746
- (_media$videoHandler$p = media.videoHandler.player) === null || _media$videoHandler$p === void 0 || _media$videoHandler$p.one('canplaythrough', function () {
74747
- resolve();
74748
- });
74749
- }));
74750
- case 4:
74751
- case "end":
74752
- return _context2.stop();
74753
- }
74754
- }, _callee2);
74755
- }));
74756
- function prepareVideo(_x3, _x4) {
74757
- return _prepareVideo.apply(this, arguments);
74758
- }
74759
- return prepareVideo;
74760
- }()
74761
- }, {
74762
- key: "prepareImage",
74763
- value: function () {
74764
- var _prepareImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(media, container) {
74765
- var blobUrl, img;
74766
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
74767
- while (1) switch (_context3.prev = _context3.next) {
74768
- case 0:
74769
- _context3.next = 2;
74770
- return BlobLoader.load(media.url);
74771
- case 2:
74772
- blobUrl = _context3.sent;
74773
- img = new Image(); // Wait for decoding to finish so there is no visual glitch
74774
- return _context3.abrupt("return", new Promise(function (resolve, reject) {
74775
- img.onload = function () {
74776
- return resolve();
74777
- };
74778
- img.onerror = function (e) {
74779
- return reject(e);
74780
- };
74781
- img.src = blobUrl;
74782
- if (media.html) {
74783
- media.html.style.setProperty('background-image', "url(".concat(blobUrl, ")"));
74784
- }
74785
- container !== null && container.appendChild(media.html);
74786
- }));
74787
- case 5:
74788
- case "end":
74789
- return _context3.stop();
74790
- }
74791
- }, _callee3);
74792
- }));
74793
- function prepareImage(_x5, _x6) {
74794
- return _prepareImage.apply(this, arguments);
74795
- }
74796
- return prepareImage;
74797
- }()
74798
- }, {
74799
- key: "prepareIframe",
74800
- value: function prepareIframe(media, container) {
74801
- console.debug('??? XLR.debug >> Region prepareIframe - start');
74802
- return new Promise(function (resolve, reject) {
74803
- var iframe = media.iframe;
74804
- console.debug('??? XLR.debug >> Region prepareIframe - promise', {
74805
- iframe: iframe,
74806
- mediaType: media.mediaType,
74807
- container: container
74808
- });
74809
- if (iframe !== null) {
74810
- iframe.onload = function () {
74811
- return resolve();
74812
- };
74813
- iframe.onerror = function (e) {
74814
- return reject(e);
74815
- };
74816
- // Append iframe to html
74817
- if (media.html) {
74818
- media.html.innerHTML = '';
74819
- media.html.appendChild(iframe);
74820
- }
74821
- container !== null && container.appendChild(media.html);
74822
- }
74823
- });
74824
- }
74825
74596
  }, {
74826
74597
  key: "run",
74827
74598
  value: function run() {
@@ -74835,7 +74606,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
74835
74606
  }, {
74836
74607
  key: "transitionNodes",
74837
74608
  value: function transitionNodes(oldMedia, newMedia) {
74838
- var _this3 = this;
74609
+ var _this2 = this;
74839
74610
  var transOutDuration = 1;
74840
74611
  var transOutDirection = 'E';
74841
74612
  if (newMedia) {
@@ -74851,7 +74622,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
74851
74622
  var transOut = transitionElement('defaultOut', {
74852
74623
  duration: defaultTransOutOptions.duration
74853
74624
  });
74854
- var transOutName;
74625
+ var transOutName = '';
74855
74626
  if (oldMedia && Boolean(oldMedia.options['transout'])) {
74856
74627
  transOutName = oldMedia.options['transout'];
74857
74628
  if (transOutName === 'fly') {
@@ -74865,11 +74636,18 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
74865
74636
  }
74866
74637
  transOut = transitionElement(transOutName, defaultTransOutOptions);
74867
74638
  }
74639
+ console.debug('??? XLR.debug >> Region > transitionNodes - transOut options', {
74640
+ transOutName: transOutName,
74641
+ transOut: transOut,
74642
+ transOutDuration: transOutDuration,
74643
+ transOutDirection: transOutDirection,
74644
+ totalMediaObjects: this.totalMediaObjects
74645
+ });
74868
74646
  var hideOldMedia = function hideOldMedia() {
74869
74647
  // Hide oldMedia
74870
74648
  if (oldMedia) {
74871
- var _this3$layout$html;
74872
- var $region = (_this3$layout$html = _this3.layout.html) === null || _this3$layout$html === void 0 ? void 0 : _this3$layout$html.querySelector('#' + _this3.containerName);
74649
+ var $layout = document.querySelector("#".concat(_this2.layout.containerName, "[data-sequence=\"").concat(_this2.layout.index, "\"]"));
74650
+ var $region = $layout.querySelector('#' + _this2.containerName);
74873
74651
  var $oldMedia = $region ? $region.querySelector('.' + getMediaId(oldMedia)) : null;
74874
74652
  if ($oldMedia) {
74875
74653
  var removeOldMedia = function removeOldMedia() {
@@ -74908,7 +74686,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
74908
74686
  if (Boolean(oldMedia.options['transout'])) {
74909
74687
  oldMediaAnimate = $oldMedia.animate(transOut.keyframes, transOut.timing);
74910
74688
  }
74911
- if (Boolean(oldMedia.options['transout']) && _this3.totalMediaObjects > 1) {
74689
+ if (Boolean(oldMedia.options['transout']) && _this2.totalMediaObjects > 1) {
74912
74690
  if (transOutName === 'flyOut') {
74913
74691
  // Reset last item to original position and state
74914
74692
  oldMediaAnimate ? oldMediaAnimate.finished.then(function () {
@@ -74934,9 +74712,6 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
74934
74712
  } else {
74935
74713
  console.debug('??? XLR.debug >> Region transitionNode - hideOldMedia' + 'no transout and only 1 media');
74936
74714
  removeOldMedia();
74937
- // Resolve this right away
74938
- // As a result, the transition between two media object
74939
- // seems like a cross-over
74940
74715
  }
74941
74716
  }
74942
74717
  }
@@ -75202,7 +74977,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
75202
74977
  };
75203
74978
  }
75204
74979
  // Only render webhook controller in CMS
75205
- if (this.parent.xlr.config.platform !== 'CMS') {
74980
+ if (this.parent.xlr.config.platform !== exports.ConsumerPlatform.CMS) {
75206
74981
  this.$actionController.style.display = 'none';
75207
74982
  return;
75208
74983
  }
@@ -75224,10 +74999,16 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
75224
74999
  }, {
75225
75000
  key: "openLayoutInNewTab",
75226
75001
  value: function openLayoutInNewTab(layoutCode, options) {
75227
- if (confirm(this.translations.navigateToLayout.replace('[layoutTag]', layoutCode))) {
75228
- var url = options.layoutPreviewUrl.replace('[layoutCode]', layoutCode) + '?findByCode=1';
75229
- window.open(url, '_blank');
75230
- }
75002
+ var url = options.layoutPreviewUrl.replace('[layoutCode]', layoutCode) + '?findByCode=1';
75003
+ // Send a postMessage to the parent frame so the CMS can handle the confirmation
75004
+ // and navigation (confirm() is blocked in sandboxed iframes without allow-modals).
75005
+ window.parent.postMessage({
75006
+ type: 'xlr:navLayout',
75007
+ layoutCode: layoutCode,
75008
+ url: url
75009
+ }, '*');
75010
+ // Also emit via the XLR event system for non-iframe consumers.
75011
+ this.parent.xlr.emitter.emit('navLayout', layoutCode, url);
75231
75012
  }
75232
75013
  }, {
75233
75014
  key: "openLayoutInPlayer",
@@ -75300,10 +75081,10 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
75300
75081
  key: "runAction",
75301
75082
  value: function runAction(actionData, options) {
75302
75083
  if (actionData.actiontype == 'navLayout') {
75303
- if (this.parent.xlr.config.platform === 'CMS') {
75084
+ if (this.parent.xlr.config.platform === exports.ConsumerPlatform.CMS) {
75304
75085
  // Open layout preview in a new tab
75305
75086
  this.openLayoutInNewTab(actionData.layoutcode, options);
75306
- } else if (this.parent.xlr.config.platform === 'chromeOS') {
75087
+ } else if (this.parent.xlr.config.platform === exports.ConsumerPlatform.CHROMEOS) {
75307
75088
  // Set target layout as active layout
75308
75089
  this.openLayoutInPlayer(actionData.layoutcode, options);
75309
75090
  }
@@ -75465,6 +75246,12 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
75465
75246
  fetchOptions.headers = {
75466
75247
  'Content-Type': 'text/xml'
75467
75248
  };
75249
+ } else if (layoutOptions.platform === exports.ConsumerPlatform.ELECTRON) {
75250
+ xlfUrl = layoutOptions.appHost + layoutOptions.xlfUrl;
75251
+ fetchOptions.mode = 'no-cors';
75252
+ fetchOptions.headers = {
75253
+ 'Content-Type': 'text/xml'
75254
+ };
75468
75255
  } else if (layoutOptions.appHost !== null) {
75469
75256
  xlfUrl = layoutOptions.appHost + layoutOptions.xlfUrl;
75470
75257
  }
@@ -75638,8 +75425,11 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
75638
75425
  layout.state = exports.ELayoutState.PLAYED;
75639
75426
  }
75640
75427
  layout.done = true;
75641
- console.debug({
75642
- $layout: $layout
75428
+ console.debug('>>> XLR.debug Layout end emitted > Layout ID > ', {
75429
+ $layout: $layout,
75430
+ layoutId: layout.id,
75431
+ isOverlay: layout.isOverlay,
75432
+ isInterrupt: layout.isInterrupt()
75643
75433
  });
75644
75434
  if ($layout !== null) {
75645
75435
  $layout.style.setProperty('visibility', 'hidden');
@@ -75794,9 +75584,10 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
75794
75584
  if (!(this.bgImage === "" || typeof this.bgImage === 'undefined')) {
75795
75585
  /* Extract the image ID from the filename */
75796
75586
  this.bgId = this.bgImage.substring(0, this.bgImage.indexOf('.'));
75797
- var bgImageUrl = composeBgUrlByPlatform(this.xlr.config.platform, _objectSpread2(_objectSpread2({}, this.options), {}, {
75798
- layout: this
75799
- }));
75587
+ var bgImageUrl = composeBgUrlByPlatform(this.xlr.config.platform, this);
75588
+ console.debug('>>> XLR.debug Layout::parseXlf - Composed background image URL > ', {
75589
+ bgImageUrl: bgImageUrl
75590
+ });
75800
75591
  if ($layout) {
75801
75592
  if (!this.isOverlay) {
75802
75593
  $layout.style.setProperty('background-image', "url(\"".concat(bgImageUrl, "\")"));
@@ -76061,7 +75852,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
76061
75852
  case 0:
76062
75853
  $previewSplash.classList.add('preview-splash');
76063
75854
  // Don't show Xibo logo on CMS Preview
76064
- if (config && config.platform !== 'CMS') {
75855
+ if (config && config.platform !== exports.ConsumerPlatform.CMS) {
76065
75856
  splashScreenImg = img$1;
76066
75857
  if ((_config$icons = config.icons) !== null && _config$icons !== void 0 && _config$icons.splashScreen && config.icons.splashScreen.length > 0) {
76067
75858
  splashScreenImg = config.icons.splashScreen;
@@ -76079,7 +75870,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
76079
75870
  $previewLoader.classList.add('preview-loader');
76080
75871
  $previewLoaderCaption.classList.add('preview-loaderCaption');
76081
75872
  // Show loader bar and text on CMS Preview
76082
- if (config && config.platform === 'CMS') {
75873
+ if (config && config.platform === exports.ConsumerPlatform.CMS) {
76083
75874
  $previewLoader.style.setProperty('background-image', "url(".concat(img, ")"));
76084
75875
  $previewLoaderCaption.innerHTML = '<p>Loading Layout...</p>';
76085
75876
  }
@@ -76373,12 +76164,12 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
76373
76164
  $splashScreen === null || $splashScreen === void 0 || $splashScreen.hide();
76374
76165
  }
76375
76166
  if (!xlr.currentLayout.done) {
76376
- console.log('>>>> XLR.debug XLR::playSchedules > Running currentLayout', xlr.currentLayout);
76377
- xlr.currentLayout.run();
76378
76167
  // Hide overlays when current layout is interrupt
76379
76168
  if (xlr.currentLayout.isInterrupt()) {
76380
76169
  xlrObject.overlayLayoutManager.stopOverlays();
76381
76170
  }
76171
+ console.log('>>>> XLR.debug XLR::playSchedules > Running currentLayout', xlr.currentLayout);
76172
+ xlr.currentLayout.run();
76382
76173
  }
76383
76174
  } else {
76384
76175
  // Show splash screen
@@ -76726,8 +76517,10 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
76726
76517
  var tempNextLayoutIndex = getLayoutIndexByLayoutId(this.inputLayouts, this.nextLayout.layoutId);
76727
76518
  _currentLayoutIndex = tempNextLayoutIndex !== null && tempNextLayoutIndex !== void 0 ? tempNextLayoutIndex : 0;
76728
76519
  _currentLayout = this.getLayout(this.inputLayouts[tempNextLayoutIndex !== null && tempNextLayoutIndex !== void 0 ? tempNextLayoutIndex : 0]);
76520
+ _currentLayout = setLayoutIndex(_currentLayout, _currentLayoutIndex);
76729
76521
  } else {
76730
76522
  _currentLayout = this.getLayout(this.inputLayouts[0]);
76523
+ _currentLayout = setLayoutIndex(_currentLayout, 0);
76731
76524
  }
76732
76525
  if (this.inputLayouts.length > 1) {
76733
76526
  if (_currentLayoutIndex + 1 > this.inputLayouts.length - 1) {
@@ -76736,6 +76529,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
76736
76529
  _nextLayoutIndex = _currentLayoutIndex + 1;
76737
76530
  }
76738
76531
  _nextLayout = this.getLayout(this.inputLayouts[_nextLayoutIndex]);
76532
+ _nextLayout = setLayoutIndex(_nextLayout, _nextLayoutIndex);
76739
76533
  } else {
76740
76534
  _nextLayout = _currentLayout;
76741
76535
  }
@@ -76748,20 +76542,25 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
76748
76542
  if (_currentLayout) {
76749
76543
  _currentLayoutIndex = _currentLayout.index;
76750
76544
  }
76545
+ _currentLayout = setLayoutIndex(_currentLayout, _currentLayoutIndex);
76751
76546
  _nextLayoutIndex = 0;
76752
76547
  _nextLayout = this.getLayout(this.inputLayouts[_nextLayoutIndex]);
76548
+ _nextLayout = setLayoutIndex(_nextLayout, _nextLayoutIndex);
76753
76549
  }
76754
76550
  } else {
76755
76551
  _currentLayoutIndex = this.nextLayout.index > this.inputLayouts.length - 1 ? 0 : this.nextLayout.index;
76756
76552
  _currentLayout = this.getLayout(this.inputLayouts[_currentLayoutIndex]);
76553
+ _currentLayout = setLayoutIndex(_currentLayout, _currentLayoutIndex);
76757
76554
  _nextLayoutIndex = _currentLayoutIndex + 1 > this.inputLayouts.length - 1 ? 0 : _currentLayoutIndex + 1;
76758
76555
  _nextLayout = this.getLayout(this.inputLayouts[_nextLayoutIndex]);
76556
+ _nextLayout = setLayoutIndex(_nextLayout, _nextLayoutIndex);
76759
76557
  }
76760
76558
  } else {
76761
76559
  _currentLayout = this.nextLayout;
76762
76560
  _currentLayoutIndex = _currentLayout.index;
76763
76561
  _nextLayoutIndex = (_currentLayoutIndex + 1) % this.inputLayouts.length;
76764
76562
  _nextLayout = this.getLayout(this.inputLayouts[_nextLayoutIndex]);
76563
+ _nextLayout = setLayoutIndex(_nextLayout, _nextLayoutIndex);
76765
76564
  }
76766
76565
  }
76767
76566
  }
@@ -76769,17 +76568,22 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
76769
76568
  // Initial run: set both currentLayout and nextLayout
76770
76569
  if (hasLayout) {
76771
76570
  _currentLayout = this.getLayout(this.inputLayouts[_currentLayoutIndex]);
76571
+ _currentLayout = setLayoutIndex(_currentLayout, _currentLayoutIndex);
76772
76572
  if (this.inputLayouts.length > 1) {
76773
76573
  _nextLayout = this.getLayout(this.inputLayouts[_nextLayoutIndex]);
76574
+ _nextLayout = setLayoutIndex(_nextLayout, _nextLayoutIndex);
76774
76575
  } else {
76775
76576
  _nextLayout = this.getLayout(this.inputLayouts[0]);
76577
+ _nextLayout = setLayoutIndex(_nextLayout, 0);
76776
76578
  }
76777
76579
  }
76778
76580
  }
76779
76581
  if (_currentLayout === undefined && _nextLayout === undefined) {
76780
76582
  if (_hasDefaultOnly) {
76781
76583
  _currentLayout = this.getLayout(this.inputLayouts[0]);
76584
+ _currentLayout = setLayoutIndex(_currentLayout, 0);
76782
76585
  _nextLayout = this.getLayout(this.inputLayouts[0]);
76586
+ _nextLayout = setLayoutIndex(_nextLayout, 0);
76783
76587
  }
76784
76588
  }
76785
76589
  if (_currentLayout !== undefined && _nextLayout !== undefined) {
@@ -76796,7 +76600,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
76796
76600
  };
76797
76601
  };
76798
76602
  xlrObject.getLayout = function (inputLayout) {
76799
- var isCMS = this.config.platform === 'CMS';
76603
+ var isCMS = this.config.platform === exports.ConsumerPlatform.CMS;
76800
76604
  if (!isCMS && Object.keys(this.uniqueLayouts).length === 0) {
76801
76605
  return;
76802
76606
  }
@@ -76813,6 +76617,11 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
76813
76617
  activeLayout = _objectSpread2({}, this.uniqueLayouts[inputLayout.layoutId]);
76814
76618
  }
76815
76619
  _layout = _objectSpread2(_objectSpread2({}, _layout), activeLayout);
76620
+ console.debug('XLR::getLayout > activeLayout from uniqueLayouts', {
76621
+ activeLayout: activeLayout,
76622
+ inputLayout: inputLayout,
76623
+ uniqueLayouts: this.uniqueLayouts
76624
+ });
76816
76625
  // Must set index/sequence from schedule loop
76817
76626
  _layout.index = activeLayout.index;
76818
76627
  }
@@ -76941,9 +76750,9 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
76941
76750
  self = this; // Compose layout props first
76942
76751
  // Clone options to avoid mutating the shared xlfUrl template
76943
76752
  newOptions = _objectSpread2({}, props.options);
76944
- if (self.config.platform === 'CMS' && inputLayout && Boolean(inputLayout.layoutId)) {
76753
+ if (self.config.platform === exports.ConsumerPlatform.CMS && inputLayout && Boolean(inputLayout.layoutId)) {
76945
76754
  newOptions.xlfUrl = newOptions.xlfUrl.replace(':layoutId', String(inputLayout.layoutId));
76946
- } else if (self.config.platform === 'chromeOS' && inputLayout !== undefined) {
76755
+ } else if ((self.config.platform === exports.ConsumerPlatform.CHROMEOS || self.config.platform === exports.ConsumerPlatform.ELECTRON) && inputLayout !== undefined) {
76947
76756
  newOptions.xlfUrl = inputLayout.path;
76948
76757
  }
76949
76758
  if (!(inputLayout && inputLayout.layoutNode === undefined)) {
@@ -77025,7 +76834,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
77025
76834
  _nextLayout = nextLayout;
77026
76835
  case 2:
77027
76836
  if (!(_nextLayout && _nextLayout.xlfString === '')) {
77028
- _context16.next = 16;
76837
+ _context16.next = 17;
77029
76838
  break;
77030
76839
  }
77031
76840
  // Remove skipped layout
@@ -77037,25 +76846,26 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
77037
76846
  _context16.next = 7;
77038
76847
  break;
77039
76848
  }
77040
- return _context16.abrupt("break", 16);
76849
+ return _context16.abrupt("break", 17);
77041
76850
  case 7:
77042
76851
  inputLayout = self.inputLayouts[nextIndex];
77043
76852
  if (inputLayout) {
77044
76853
  _context16.next = 10;
77045
76854
  break;
77046
76855
  }
77047
- return _context16.abrupt("break", 16);
76856
+ return _context16.abrupt("break", 17);
77048
76857
  case 10:
77049
76858
  nextLayoutObj = self.getLayout(inputLayout);
77050
- _context16.next = 13;
76859
+ nextLayoutObj = setLayoutIndex(nextLayoutObj, nextIndex);
76860
+ _context16.next = 14;
77051
76861
  return self.prepareLayoutXlf(nextLayoutObj);
77052
- case 13:
76862
+ case 14:
77053
76863
  _nextLayout = _context16.sent;
77054
76864
  _context16.next = 2;
77055
76865
  break;
77056
- case 16:
77057
- return _context16.abrupt("return", _nextLayout);
77058
76866
  case 17:
76867
+ return _context16.abrupt("return", _nextLayout);
76868
+ case 18:
77059
76869
  case "end":
77060
76870
  return _context16.stop();
77061
76871
  }
@@ -77171,13 +76981,16 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
77171
76981
  exports.flyInElem = flyInElem;
77172
76982
  exports.flyOutElem = flyOutElem;
77173
76983
  exports.flyTransitionKeyframes = flyTransitionKeyframes;
76984
+ exports.getAllAttributes = getAllAttributes;
77174
76985
  exports.getDataBlob = getDataBlob;
77175
76986
  exports.getFileExt = getFileExt;
77176
76987
  exports.getIndexByLayoutId = getIndexByLayoutId;
77177
76988
  exports.getLayout = getLayout;
76989
+ exports.getLayoutIndexByLayoutId = getLayoutIndexByLayoutId;
77178
76990
  exports.getMediaId = getMediaId;
77179
76991
  exports.getXlf = getXlf;
77180
76992
  exports.hasDefaultOnly = hasDefaultOnly;
76993
+ exports.hasSspLayout = hasSspLayout;
77181
76994
  exports.initRenderingDOM = initRenderingDOM;
77182
76995
  exports.initialLayout = initialLayout;
77183
76996
  exports.initialMedia = initialMedia;
@@ -77186,11 +76999,15 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
77186
76999
  exports.isEmpty = isEmpty;
77187
77000
  exports.isLayoutValid = isLayoutValid;
77188
77001
  exports.nextId = nextId;
77002
+ exports.playerReportFault = playerReportFault;
77189
77003
  exports.preloadMediaBlob = preloadMediaBlob;
77004
+ exports.prepareAudioMedia = prepareAudioMedia;
77005
+ exports.prepareHtmlMedia = prepareHtmlMedia;
77006
+ exports.prepareImageMedia = prepareImageMedia;
77007
+ exports.prepareVideoMedia = prepareVideoMedia;
77190
77008
  exports.setExpiry = setExpiry;
77191
77009
  exports.transitionElement = transitionElement;
77192
77010
  exports.videoFileType = videoFileType;
77193
- exports.videoMediaHandler = videoMediaHandler;
77194
77011
  exports.vjsDefaultOptions = vjsDefaultOptions;
77195
77012
 
77196
77013
  Object.defineProperty(exports, '__esModule', { value: true });