@xibosignage/xibo-layout-renderer 1.0.15 → 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.
@@ -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,13 +72666,13 @@ function composeVideoSource($media, media) {
72635
72666
  return $media;
72636
72667
  }
72637
72668
  function VideoMedia(media, xlr) {
72638
- return {
72669
+ var videoMediaInstance = {
72639
72670
  init: function init() {
72640
72671
  var vjsPlayer = media.player;
72641
72672
  if (vjsPlayer !== undefined) {
72642
72673
  var playerReportFault = /*#__PURE__*/function () {
72643
72674
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(msg) {
72644
- var playerSW, hasSW, endVideo;
72675
+ var playerSW, hasSW;
72645
72676
  return _regeneratorRuntime().wrap(function _callee$(_context) {
72646
72677
  while (1) switch (_context.prev = _context.next) {
72647
72678
  case 0:
@@ -72651,11 +72682,6 @@ function VideoMedia(media, xlr) {
72651
72682
  return playerSW.getSW();
72652
72683
  case 3:
72653
72684
  hasSW = _context.sent;
72654
- endVideo = function endVideo() {
72655
- // Expire the media and dispose the video
72656
- vjsPlayer.dispose();
72657
- media.emitter.emit('end', media);
72658
- };
72659
72685
  if (hasSW) {
72660
72686
  playerSW.postMsg({
72661
72687
  type: 'MEDIA_FAULT',
@@ -72668,12 +72694,12 @@ function VideoMedia(media, xlr) {
72668
72694
  // Temporary setting
72669
72695
  expires: format(new Date(setExpiry(1)), 'yyyy-MM-dd HH:mm:ss')
72670
72696
  })["finally"](function () {
72671
- endVideo();
72697
+ videoMediaInstance.stop();
72672
72698
  });
72673
72699
  } else {
72674
- endVideo();
72700
+ videoMediaInstance.stop();
72675
72701
  }
72676
- case 6:
72702
+ case 5:
72677
72703
  case "end":
72678
72704
  return _context.stop();
72679
72705
  }
@@ -72726,28 +72752,26 @@ function VideoMedia(media, xlr) {
72726
72752
  console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Autoplay started"));
72727
72753
  })["catch"]( /*#__PURE__*/function () {
72728
72754
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(error) {
72729
- var _media$emitter;
72730
72755
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
72731
72756
  while (1) switch (_context3.prev = _context3.next) {
72732
72757
  case 0:
72733
72758
  if (!(error === 'Timeout')) {
72734
- _context3.next = 6;
72759
+ _context3.next = 5;
72735
72760
  break;
72736
72761
  }
72737
72762
  console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Promise not resolved within 5 seconds. Move to next media"));
72738
- vjsPlayer.dispose();
72739
- (_media$emitter = media.emitter) === null || _media$emitter === void 0 || _media$emitter.emit('end', media);
72740
- _context3.next = 10;
72763
+ videoMediaInstance.stop();
72764
+ _context3.next = 9;
72741
72765
  break;
72742
- case 6:
72766
+ case 5:
72743
72767
  console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Autoplay error: ").concat(error));
72744
72768
  if (!(xlr.config.platform === 'chromeOS')) {
72745
- _context3.next = 10;
72769
+ _context3.next = 9;
72746
72770
  break;
72747
72771
  }
72748
- _context3.next = 10;
72772
+ _context3.next = 9;
72749
72773
  return playerReportFault('Media autoplay error');
72750
- case 10:
72774
+ case 9:
72751
72775
  case "end":
72752
72776
  return _context3.stop();
72753
72777
  }
@@ -72781,8 +72805,7 @@ function VideoMedia(media, xlr) {
72781
72805
  // End media after 5 seconds
72782
72806
  setTimeout(function () {
72783
72807
  console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has ended . . ."));
72784
- media.emitter.emit('end', media);
72785
- vjsPlayer.dispose();
72808
+ videoMediaInstance.stop();
72786
72809
  }, 5000);
72787
72810
  case 7:
72788
72811
  case "end":
@@ -72794,23 +72817,30 @@ function VideoMedia(media, xlr) {
72794
72817
  return _ref4.apply(this, arguments);
72795
72818
  };
72796
72819
  }());
72797
- vjsPlayer.on('ended', function () {
72798
- var _media$emitter2;
72799
- console.debug("VideoMedia: onended: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has ended playing . . ."));
72800
- (_media$emitter2 = media.emitter) === null || _media$emitter2 === void 0 || _media$emitter2.emit('end', media);
72801
- vjsPlayer.dispose();
72802
- });
72803
- vjsPlayer.on('durationchange', function () {
72804
- if (media.duration === 0 && vjsPlayer.duration() !== undefined) {
72805
- media.duration = vjsPlayer.duration();
72806
- } else if (media.duration > 0) {
72807
- vjsPlayer.duration(media.duration);
72808
- }
72809
- console.debug('VIDEOJS: ondurationchange: Showing Media ' + media.id + ' for ' + vjsPlayer.duration() + 's of Region ' + media.region.regionId);
72810
- });
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();
72811
72840
  }
72812
72841
  }
72813
72842
  };
72843
+ return videoMediaInstance;
72814
72844
  }
72815
72845
 
72816
72846
  function AudioMedia(media) {
@@ -72890,6 +72920,11 @@ function Media(region, mediaId, xml, options, xlr) {
72890
72920
  if (mediaTimeCount > media.duration) {
72891
72921
  console.debug('startMediaTimer: emit>end: on media ' + media.id + ' of Region ' + media.region.regionId);
72892
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
+ }
72893
72928
  }
72894
72929
  }, 1000);
72895
72930
  console.debug('startMediaTimer: Showing Media ' + media.id + ' for ' + media.duration + 's of Region ' + media.region.regionId);
@@ -74686,5 +74721,5 @@ function XiboLayoutRenderer(inputLayouts, options) {
74686
74721
  return xlrObject;
74687
74722
  }
74688
74723
 
74689
- 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 };
74690
74725
  //# sourceMappingURL=xibo-layout-renderer.esm.js.map