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