@xibosignage/xibo-layout-renderer 1.0.14 → 1.0.16
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/dist/src/Modules/Generators/index.d.ts +1 -1
- package/dist/src/Modules/Media/VideoMedia.d.ts +1 -0
- package/dist/xibo-layout-renderer.cjs.js +143 -57
- package/dist/xibo-layout-renderer.cjs.js.map +1 -1
- package/dist/xibo-layout-renderer.d.ts +19 -1
- package/dist/xibo-layout-renderer.esm.js +136 -58
- package/dist/xibo-layout-renderer.esm.js.map +1 -1
- package/dist/xibo-layout-renderer.js +143 -57
- package/dist/xibo-layout-renderer.min.js +8 -8
- package/dist/xibo-layout-renderer.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -254,12 +254,29 @@ declare function nextId(options: {
|
|
|
254
254
|
}): number;
|
|
255
255
|
declare const getMediaId: ({ mediaType, containerName }: IMedia) => string;
|
|
256
256
|
declare const capitalizeStr: (inputStr: string) => string;
|
|
257
|
+
declare function getDataBlob(src: string): Promise<unknown>;
|
|
257
258
|
type MediaTypes = 'video' | 'audio' | 'image';
|
|
258
259
|
declare function preloadMediaBlob(src: string, type: MediaTypes): Promise<string>;
|
|
259
260
|
declare function fetchJSON(url: string): Promise<any>;
|
|
261
|
+
declare function fetchText(url: string): Promise<string>;
|
|
260
262
|
declare function getFileExt(filename: string): string;
|
|
261
263
|
declare function audioFileType(str: string): string | undefined;
|
|
262
264
|
declare function videoFileType(str: string): string | undefined;
|
|
265
|
+
declare function composeResourceUrlByPlatform(options: OptionsType, params: any): string;
|
|
266
|
+
declare function composeResourceUrl(options: OptionsType, params: any): string;
|
|
267
|
+
declare function composeMediaUrl(params: any): string;
|
|
268
|
+
declare function composeBgUrlByPlatform(platform: OptionsType['platform'], params: any): string;
|
|
269
|
+
type LayoutIndexType = {
|
|
270
|
+
[k: string]: InputLayoutType & {
|
|
271
|
+
index: number;
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
declare function getIndexByLayoutId(layoutsInput: InputLayoutType[], layoutId?: number | null): (InputLayoutType & {
|
|
275
|
+
index: number;
|
|
276
|
+
}) | LayoutIndexType | {
|
|
277
|
+
index: number;
|
|
278
|
+
};
|
|
279
|
+
declare function isEmpty(input: any): boolean;
|
|
263
280
|
/**
|
|
264
281
|
* Create expiration day based on current date
|
|
265
282
|
* @param numDays Number of days as expiry
|
|
@@ -269,6 +286,7 @@ declare function setExpiry(numDays: number): string;
|
|
|
269
286
|
|
|
270
287
|
declare function VideoMedia(media: IMedia, xlr: IXlr): {
|
|
271
288
|
init: () => void;
|
|
289
|
+
stop: (disposeOnly?: boolean) => void;
|
|
272
290
|
};
|
|
273
291
|
|
|
274
292
|
declare function AudioMedia(media: IMedia): {
|
|
@@ -379,4 +397,4 @@ type flyTransitionParams = {
|
|
|
379
397
|
};
|
|
380
398
|
declare const flyTransitionKeyframes: (params: flyTransitionParams) => KeyframeOptionsType;
|
|
381
399
|
|
|
382
|
-
export { Action, ActionsWrapper, AudioMedia, ELayoutType, type GetLayoutParamType, type GetLayoutType, type ILayout, type ILayoutEvents, type IMedia, type IRegion, type IRegionEvents, type ISplashScreen, type IXlr, type InactOptions, type InputLayoutType, type KeyframeOptionsType, Media, type MediaTypes, type OptionsType, type PreviewSplashElement, Region, type TransitionElementOptions, type TransitionNameType, VideoMedia, audioFileType, capitalizeStr, type compassPoints, XiboLayoutRenderer as default, defaultTrans, fadeInElem, fadeOutElem, fetchJSON, flyInElem, flyOutElem, flyTransitionKeyframes, type flyTransitionParams, getFileExt, getLayout, getMediaId, getXlf, initRenderingDOM, initialLayout, initialMedia, initialRegion, initialXlr, nextId, platform, preloadMediaBlob, setExpiry, transitionElement, videoFileType };
|
|
400
|
+
export { Action, ActionsWrapper, AudioMedia, ELayoutType, type GetLayoutParamType, type GetLayoutType, type ILayout, type ILayoutEvents, type IMedia, type IRegion, type IRegionEvents, type ISplashScreen, type IXlr, type InactOptions, type InputLayoutType, type KeyframeOptionsType, Media, type MediaTypes, type OptionsType, type PreviewSplashElement, Region, type TransitionElementOptions, type TransitionNameType, VideoMedia, audioFileType, capitalizeStr, type compassPoints, composeBgUrlByPlatform, composeMediaUrl, composeResourceUrl, composeResourceUrlByPlatform, XiboLayoutRenderer as default, defaultTrans, fadeInElem, fadeOutElem, fetchJSON, fetchText, flyInElem, flyOutElem, flyTransitionKeyframes, type flyTransitionParams, getDataBlob, getFileExt, getIndexByLayoutId, getLayout, getMediaId, getXlf, initRenderingDOM, initialLayout, initialMedia, initialRegion, initialXlr, isEmpty, nextId, platform, preloadMediaBlob, setExpiry, transitionElement, videoFileType };
|
|
@@ -795,6 +795,34 @@ function _fetchJSON() {
|
|
|
795
795
|
}));
|
|
796
796
|
return _fetchJSON.apply(this, arguments);
|
|
797
797
|
}
|
|
798
|
+
function fetchText(_x5) {
|
|
799
|
+
return _fetchText.apply(this, arguments);
|
|
800
|
+
}
|
|
801
|
+
function _fetchText() {
|
|
802
|
+
_fetchText = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(url) {
|
|
803
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
804
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
805
|
+
case 0:
|
|
806
|
+
return _context4.abrupt("return", fetch(url).then(function (res) {
|
|
807
|
+
return res.text();
|
|
808
|
+
}).then(function (responseText) {
|
|
809
|
+
if (String(responseText).length > 0) {
|
|
810
|
+
return responseText;
|
|
811
|
+
} else {
|
|
812
|
+
return '';
|
|
813
|
+
}
|
|
814
|
+
})["catch"](function (err) {
|
|
815
|
+
console.debug(err);
|
|
816
|
+
return err === null || err === void 0 ? void 0 : err.message;
|
|
817
|
+
}));
|
|
818
|
+
case 1:
|
|
819
|
+
case "end":
|
|
820
|
+
return _context4.stop();
|
|
821
|
+
}
|
|
822
|
+
}, _callee4);
|
|
823
|
+
}));
|
|
824
|
+
return _fetchText.apply(this, arguments);
|
|
825
|
+
}
|
|
798
826
|
function getFileExt(filename) {
|
|
799
827
|
var filenameArr = String(filename).split('.');
|
|
800
828
|
return filenameArr[filenameArr.length - 1];
|
|
@@ -870,6 +898,9 @@ function getIndexByLayoutId(layoutsInput, layoutId) {
|
|
|
870
898
|
index: 0
|
|
871
899
|
};
|
|
872
900
|
}
|
|
901
|
+
function isEmpty$1(input) {
|
|
902
|
+
return !Boolean(input) || String(input).length === 0;
|
|
903
|
+
}
|
|
873
904
|
function getAllAttributes(elem) {
|
|
874
905
|
if (!elem || elem === null) {
|
|
875
906
|
return {};
|
|
@@ -72635,7 +72666,7 @@ function composeVideoSource($media, media) {
|
|
|
72635
72666
|
return $media;
|
|
72636
72667
|
}
|
|
72637
72668
|
function VideoMedia(media, xlr) {
|
|
72638
|
-
|
|
72669
|
+
var videoMediaInstance = {
|
|
72639
72670
|
init: function init() {
|
|
72640
72671
|
var vjsPlayer = media.player;
|
|
72641
72672
|
if (vjsPlayer !== undefined) {
|
|
@@ -72663,10 +72694,10 @@ function VideoMedia(media, xlr) {
|
|
|
72663
72694
|
// Temporary setting
|
|
72664
72695
|
expires: format(new Date(setExpiry(1)), 'yyyy-MM-dd HH:mm:ss')
|
|
72665
72696
|
})["finally"](function () {
|
|
72666
|
-
|
|
72667
|
-
vjsPlayer.dispose();
|
|
72668
|
-
media.emitter.emit('end', media);
|
|
72697
|
+
videoMediaInstance.stop();
|
|
72669
72698
|
});
|
|
72699
|
+
} else {
|
|
72700
|
+
videoMediaInstance.stop();
|
|
72670
72701
|
}
|
|
72671
72702
|
case 5:
|
|
72672
72703
|
case "end":
|
|
@@ -72686,88 +72717,130 @@ function VideoMedia(media, xlr) {
|
|
|
72686
72717
|
});
|
|
72687
72718
|
vjsPlayer.on('ready', function () {
|
|
72688
72719
|
vjsPlayer.muted(true);
|
|
72689
|
-
|
|
72690
|
-
|
|
72691
|
-
|
|
72692
|
-
|
|
72693
|
-
|
|
72694
|
-
|
|
72695
|
-
|
|
72696
|
-
|
|
72697
|
-
|
|
72698
|
-
|
|
72699
|
-
|
|
72700
|
-
|
|
72701
|
-
|
|
72702
|
-
|
|
72703
|
-
|
|
72704
|
-
|
|
72705
|
-
|
|
72706
|
-
|
|
72707
|
-
|
|
72708
|
-
|
|
72709
|
-
|
|
72710
|
-
|
|
72711
|
-
|
|
72712
|
-
|
|
72713
|
-
|
|
72714
|
-
};
|
|
72715
|
-
}
|
|
72716
|
-
}
|
|
72720
|
+
// Race promise between a 0.5s play and a 5s skip
|
|
72721
|
+
Promise.race([new Promise(function (resolve, reject) {
|
|
72722
|
+
return setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
72723
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
72724
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
72725
|
+
case 0:
|
|
72726
|
+
console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Trying to force play after 0.1 seconds"));
|
|
72727
|
+
// Try to force play here
|
|
72728
|
+
_context2.prev = 1;
|
|
72729
|
+
_context2.next = 4;
|
|
72730
|
+
return vjsPlayer.play();
|
|
72731
|
+
case 4:
|
|
72732
|
+
// Resolve if play works
|
|
72733
|
+
resolve(true);
|
|
72734
|
+
_context2.next = 10;
|
|
72735
|
+
break;
|
|
72736
|
+
case 7:
|
|
72737
|
+
_context2.prev = 7;
|
|
72738
|
+
_context2.t0 = _context2["catch"](1);
|
|
72739
|
+
// Reject race if play fails
|
|
72740
|
+
reject('Play failed');
|
|
72741
|
+
case 10:
|
|
72742
|
+
case "end":
|
|
72743
|
+
return _context2.stop();
|
|
72744
|
+
}
|
|
72745
|
+
}, _callee2, null, [[1, 7]]);
|
|
72746
|
+
})), 100);
|
|
72747
|
+
}), new Promise(function (_, reject) {
|
|
72748
|
+
return setTimeout(function () {
|
|
72749
|
+
return reject('Timeout');
|
|
72750
|
+
}, 5000);
|
|
72751
|
+
})]).then(function () {
|
|
72752
|
+
console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Autoplay started"));
|
|
72753
|
+
})["catch"]( /*#__PURE__*/function () {
|
|
72754
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(error) {
|
|
72755
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
72756
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
72757
|
+
case 0:
|
|
72758
|
+
if (!(error === 'Timeout')) {
|
|
72759
|
+
_context3.next = 5;
|
|
72760
|
+
break;
|
|
72761
|
+
}
|
|
72762
|
+
console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Promise not resolved within 5 seconds. Move to next media"));
|
|
72763
|
+
videoMediaInstance.stop();
|
|
72764
|
+
_context3.next = 9;
|
|
72765
|
+
break;
|
|
72766
|
+
case 5:
|
|
72767
|
+
console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Autoplay error: ").concat(error));
|
|
72768
|
+
if (!(xlr.config.platform === 'chromeOS')) {
|
|
72769
|
+
_context3.next = 9;
|
|
72770
|
+
break;
|
|
72771
|
+
}
|
|
72772
|
+
_context3.next = 9;
|
|
72773
|
+
return playerReportFault('Media autoplay error');
|
|
72774
|
+
case 9:
|
|
72775
|
+
case "end":
|
|
72776
|
+
return _context3.stop();
|
|
72777
|
+
}
|
|
72778
|
+
}, _callee3);
|
|
72779
|
+
}));
|
|
72780
|
+
return function (_x2) {
|
|
72781
|
+
return _ref3.apply(this, arguments);
|
|
72782
|
+
};
|
|
72783
|
+
}());
|
|
72717
72784
|
});
|
|
72718
72785
|
vjsPlayer.on('playing', function () {
|
|
72719
72786
|
console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " is now playing . . ."));
|
|
72720
72787
|
vjsPlayer.muted(media.muted);
|
|
72721
72788
|
});
|
|
72722
72789
|
vjsPlayer.on('error', /*#__PURE__*/function () {
|
|
72723
|
-
var
|
|
72724
|
-
return _regeneratorRuntime().wrap(function
|
|
72725
|
-
while (1) switch (
|
|
72790
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(err) {
|
|
72791
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
72792
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
72726
72793
|
case 0:
|
|
72727
72794
|
console.debug("Media Error: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id));
|
|
72728
72795
|
if (!(xlr.config.platform === 'chromeOS')) {
|
|
72729
|
-
|
|
72796
|
+
_context4.next = 6;
|
|
72730
72797
|
break;
|
|
72731
72798
|
}
|
|
72732
|
-
|
|
72799
|
+
_context4.next = 4;
|
|
72733
72800
|
return playerReportFault('Video file source not supported');
|
|
72734
72801
|
case 4:
|
|
72735
|
-
|
|
72802
|
+
_context4.next = 7;
|
|
72736
72803
|
break;
|
|
72737
72804
|
case 6:
|
|
72738
72805
|
// End media after 5 seconds
|
|
72739
72806
|
setTimeout(function () {
|
|
72740
72807
|
console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has ended . . ."));
|
|
72741
|
-
|
|
72742
|
-
vjsPlayer.dispose();
|
|
72808
|
+
videoMediaInstance.stop();
|
|
72743
72809
|
}, 5000);
|
|
72744
72810
|
case 7:
|
|
72745
72811
|
case "end":
|
|
72746
|
-
return
|
|
72812
|
+
return _context4.stop();
|
|
72747
72813
|
}
|
|
72748
|
-
},
|
|
72814
|
+
}, _callee4);
|
|
72749
72815
|
}));
|
|
72750
72816
|
return function (_x3) {
|
|
72751
|
-
return
|
|
72817
|
+
return _ref4.apply(this, arguments);
|
|
72752
72818
|
};
|
|
72753
72819
|
}());
|
|
72754
|
-
|
|
72755
|
-
|
|
72756
|
-
|
|
72757
|
-
|
|
72758
|
-
|
|
72759
|
-
|
|
72760
|
-
|
|
72761
|
-
|
|
72762
|
-
|
|
72763
|
-
|
|
72764
|
-
|
|
72765
|
-
|
|
72766
|
-
|
|
72767
|
-
|
|
72820
|
+
if (media.duration === 0) {
|
|
72821
|
+
vjsPlayer.on('ended', function () {
|
|
72822
|
+
console.debug("VideoMedia: onended: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has ended playing . . ."));
|
|
72823
|
+
videoMediaInstance.stop();
|
|
72824
|
+
});
|
|
72825
|
+
vjsPlayer.on('durationchange', function () {
|
|
72826
|
+
console.debug('VIDEOJS: ondurationchange: Showing Media ' + media.id + ' for ' + vjsPlayer.duration() + 's of Region ' + media.region.regionId);
|
|
72827
|
+
});
|
|
72828
|
+
}
|
|
72829
|
+
}
|
|
72830
|
+
},
|
|
72831
|
+
stop: function stop() {
|
|
72832
|
+
var disposeOnly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
72833
|
+
var vjsPlayer = media.player;
|
|
72834
|
+
// Expire the media and dispose the video
|
|
72835
|
+
if (vjsPlayer !== undefined) {
|
|
72836
|
+
if (!disposeOnly) {
|
|
72837
|
+
media.emitter.emit('end', media);
|
|
72838
|
+
}
|
|
72839
|
+
vjsPlayer.dispose();
|
|
72768
72840
|
}
|
|
72769
72841
|
}
|
|
72770
72842
|
};
|
|
72843
|
+
return videoMediaInstance;
|
|
72771
72844
|
}
|
|
72772
72845
|
|
|
72773
72846
|
function AudioMedia(media) {
|
|
@@ -72847,6 +72920,11 @@ function Media(region, mediaId, xml, options, xlr) {
|
|
|
72847
72920
|
if (mediaTimeCount > media.duration) {
|
|
72848
72921
|
console.debug('startMediaTimer: emit>end: on media ' + media.id + ' of Region ' + media.region.regionId);
|
|
72849
72922
|
media.emitter.emit('end', media);
|
|
72923
|
+
if (media.mediaType === 'video') {
|
|
72924
|
+
// Dispose the video media
|
|
72925
|
+
console.debug("VideoMedia::stop - ".concat(capitalizeStr(media.mediaType), " for media ").concat(media.id, " has been stopped."));
|
|
72926
|
+
VideoMedia(media, xlr).stop(true);
|
|
72927
|
+
}
|
|
72850
72928
|
}
|
|
72851
72929
|
}, 1000);
|
|
72852
72930
|
console.debug('startMediaTimer: Showing Media ' + media.id + ' for ' + media.duration + 's of Region ' + media.region.regionId);
|
|
@@ -74643,5 +74721,5 @@ function XiboLayoutRenderer(inputLayouts, options) {
|
|
|
74643
74721
|
return xlrObject;
|
|
74644
74722
|
}
|
|
74645
74723
|
|
|
74646
|
-
export { Action, ActionsWrapper, AudioMedia, ELayoutType, Media, Region, VideoMedia, audioFileType, capitalizeStr, XiboLayoutRenderer as default, defaultTrans, fadeInElem, fadeOutElem, fetchJSON, flyInElem, flyOutElem, flyTransitionKeyframes, getFileExt, getLayout, getMediaId, getXlf, initRenderingDOM, initialLayout, initialMedia, initialRegion, initialXlr, nextId, platform, preloadMediaBlob, setExpiry, transitionElement, videoFileType };
|
|
74724
|
+
export { Action, ActionsWrapper, AudioMedia, ELayoutType, Media, Region, VideoMedia, audioFileType, capitalizeStr, composeBgUrlByPlatform, composeMediaUrl, composeResourceUrl, composeResourceUrlByPlatform, XiboLayoutRenderer as default, defaultTrans, fadeInElem, fadeOutElem, fetchJSON, fetchText, flyInElem, flyOutElem, flyTransitionKeyframes, getDataBlob, getFileExt, getIndexByLayoutId, getLayout, getMediaId, getXlf, initRenderingDOM, initialLayout, initialMedia, initialRegion, initialXlr, isEmpty$1 as isEmpty, nextId, platform, preloadMediaBlob, setExpiry, transitionElement, videoFileType };
|
|
74647
74725
|
//# sourceMappingURL=xibo-layout-renderer.esm.js.map
|