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