@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.
@@ -1 +1 @@
1
- export { getFileExt, nextId, preloadMediaBlob, getMediaId, fetchJSON, capitalizeStr, audioFileType, MediaTypes, videoFileType, setExpiry, } from './Generators';
1
+ export { getFileExt, nextId, preloadMediaBlob, getMediaId, fetchJSON, capitalizeStr, audioFileType, MediaTypes, videoFileType, setExpiry, composeMediaUrl, fetchText, getDataBlob, composeResourceUrl, composeResourceUrlByPlatform, getIndexByLayoutId, isEmpty, composeBgUrlByPlatform, } from './Generators';
@@ -4,4 +4,5 @@ import './media.css';
4
4
  export declare function composeVideoSource($media: HTMLVideoElement, media: IMedia): HTMLVideoElement;
5
5
  export default function VideoMedia(media: IMedia, xlr: IXlr): {
6
6
  init: () => void;
7
+ stop: (disposeOnly?: boolean) => void;
7
8
  };
@@ -799,6 +799,34 @@ function _fetchJSON() {
799
799
  }));
800
800
  return _fetchJSON.apply(this, arguments);
801
801
  }
802
+ function fetchText(_x5) {
803
+ return _fetchText.apply(this, arguments);
804
+ }
805
+ function _fetchText() {
806
+ _fetchText = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(url) {
807
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
808
+ while (1) switch (_context4.prev = _context4.next) {
809
+ case 0:
810
+ return _context4.abrupt("return", fetch(url).then(function (res) {
811
+ return res.text();
812
+ }).then(function (responseText) {
813
+ if (String(responseText).length > 0) {
814
+ return responseText;
815
+ } else {
816
+ return '';
817
+ }
818
+ })["catch"](function (err) {
819
+ console.debug(err);
820
+ return err === null || err === void 0 ? void 0 : err.message;
821
+ }));
822
+ case 1:
823
+ case "end":
824
+ return _context4.stop();
825
+ }
826
+ }, _callee4);
827
+ }));
828
+ return _fetchText.apply(this, arguments);
829
+ }
802
830
  function getFileExt(filename) {
803
831
  var filenameArr = String(filename).split('.');
804
832
  return filenameArr[filenameArr.length - 1];
@@ -874,6 +902,9 @@ function getIndexByLayoutId(layoutsInput, layoutId) {
874
902
  index: 0
875
903
  };
876
904
  }
905
+ function isEmpty$1(input) {
906
+ return !Boolean(input) || String(input).length === 0;
907
+ }
877
908
  function getAllAttributes(elem) {
878
909
  if (!elem || elem === null) {
879
910
  return {};
@@ -72639,13 +72670,13 @@ function composeVideoSource($media, media) {
72639
72670
  return $media;
72640
72671
  }
72641
72672
  function VideoMedia(media, xlr) {
72642
- return {
72673
+ var videoMediaInstance = {
72643
72674
  init: function init() {
72644
72675
  var vjsPlayer = media.player;
72645
72676
  if (vjsPlayer !== undefined) {
72646
72677
  var playerReportFault = /*#__PURE__*/function () {
72647
72678
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(msg) {
72648
- var playerSW, hasSW, endVideo;
72679
+ var playerSW, hasSW;
72649
72680
  return _regeneratorRuntime().wrap(function _callee$(_context) {
72650
72681
  while (1) switch (_context.prev = _context.next) {
72651
72682
  case 0:
@@ -72655,11 +72686,6 @@ function VideoMedia(media, xlr) {
72655
72686
  return playerSW.getSW();
72656
72687
  case 3:
72657
72688
  hasSW = _context.sent;
72658
- endVideo = function endVideo() {
72659
- // Expire the media and dispose the video
72660
- vjsPlayer.dispose();
72661
- media.emitter.emit('end', media);
72662
- };
72663
72689
  if (hasSW) {
72664
72690
  playerSW.postMsg({
72665
72691
  type: 'MEDIA_FAULT',
@@ -72672,12 +72698,12 @@ function VideoMedia(media, xlr) {
72672
72698
  // Temporary setting
72673
72699
  expires: format(new Date(setExpiry(1)), 'yyyy-MM-dd HH:mm:ss')
72674
72700
  })["finally"](function () {
72675
- endVideo();
72701
+ videoMediaInstance.stop();
72676
72702
  });
72677
72703
  } else {
72678
- endVideo();
72704
+ videoMediaInstance.stop();
72679
72705
  }
72680
- case 6:
72706
+ case 5:
72681
72707
  case "end":
72682
72708
  return _context.stop();
72683
72709
  }
@@ -72730,28 +72756,26 @@ function VideoMedia(media, xlr) {
72730
72756
  console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Autoplay started"));
72731
72757
  })["catch"]( /*#__PURE__*/function () {
72732
72758
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(error) {
72733
- var _media$emitter;
72734
72759
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
72735
72760
  while (1) switch (_context3.prev = _context3.next) {
72736
72761
  case 0:
72737
72762
  if (!(error === 'Timeout')) {
72738
- _context3.next = 6;
72763
+ _context3.next = 5;
72739
72764
  break;
72740
72765
  }
72741
72766
  console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Promise not resolved within 5 seconds. Move to next media"));
72742
- vjsPlayer.dispose();
72743
- (_media$emitter = media.emitter) === null || _media$emitter === void 0 || _media$emitter.emit('end', media);
72744
- _context3.next = 10;
72767
+ videoMediaInstance.stop();
72768
+ _context3.next = 9;
72745
72769
  break;
72746
- case 6:
72770
+ case 5:
72747
72771
  console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Autoplay error: ").concat(error));
72748
72772
  if (!(xlr.config.platform === 'chromeOS')) {
72749
- _context3.next = 10;
72773
+ _context3.next = 9;
72750
72774
  break;
72751
72775
  }
72752
- _context3.next = 10;
72776
+ _context3.next = 9;
72753
72777
  return playerReportFault('Media autoplay error');
72754
- case 10:
72778
+ case 9:
72755
72779
  case "end":
72756
72780
  return _context3.stop();
72757
72781
  }
@@ -72785,8 +72809,7 @@ function VideoMedia(media, xlr) {
72785
72809
  // End media after 5 seconds
72786
72810
  setTimeout(function () {
72787
72811
  console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has ended . . ."));
72788
- media.emitter.emit('end', media);
72789
- vjsPlayer.dispose();
72812
+ videoMediaInstance.stop();
72790
72813
  }, 5000);
72791
72814
  case 7:
72792
72815
  case "end":
@@ -72798,23 +72821,30 @@ function VideoMedia(media, xlr) {
72798
72821
  return _ref4.apply(this, arguments);
72799
72822
  };
72800
72823
  }());
72801
- vjsPlayer.on('ended', function () {
72802
- var _media$emitter2;
72803
- console.debug("VideoMedia: onended: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has ended playing . . ."));
72804
- (_media$emitter2 = media.emitter) === null || _media$emitter2 === void 0 || _media$emitter2.emit('end', media);
72805
- vjsPlayer.dispose();
72806
- });
72807
- vjsPlayer.on('durationchange', function () {
72808
- if (media.duration === 0 && vjsPlayer.duration() !== undefined) {
72809
- media.duration = vjsPlayer.duration();
72810
- } else if (media.duration > 0) {
72811
- vjsPlayer.duration(media.duration);
72812
- }
72813
- console.debug('VIDEOJS: ondurationchange: Showing Media ' + media.id + ' for ' + vjsPlayer.duration() + 's of Region ' + media.region.regionId);
72814
- });
72824
+ if (media.duration === 0) {
72825
+ vjsPlayer.on('ended', function () {
72826
+ console.debug("VideoMedia: onended: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has ended playing . . ."));
72827
+ videoMediaInstance.stop();
72828
+ });
72829
+ vjsPlayer.on('durationchange', function () {
72830
+ console.debug('VIDEOJS: ondurationchange: Showing Media ' + media.id + ' for ' + vjsPlayer.duration() + 's of Region ' + media.region.regionId);
72831
+ });
72832
+ }
72833
+ }
72834
+ },
72835
+ stop: function stop() {
72836
+ var disposeOnly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
72837
+ var vjsPlayer = media.player;
72838
+ // Expire the media and dispose the video
72839
+ if (vjsPlayer !== undefined) {
72840
+ if (!disposeOnly) {
72841
+ media.emitter.emit('end', media);
72842
+ }
72843
+ vjsPlayer.dispose();
72815
72844
  }
72816
72845
  }
72817
72846
  };
72847
+ return videoMediaInstance;
72818
72848
  }
72819
72849
 
72820
72850
  function AudioMedia(media) {
@@ -72894,6 +72924,11 @@ function Media(region, mediaId, xml, options, xlr) {
72894
72924
  if (mediaTimeCount > media.duration) {
72895
72925
  console.debug('startMediaTimer: emit>end: on media ' + media.id + ' of Region ' + media.region.regionId);
72896
72926
  media.emitter.emit('end', media);
72927
+ if (media.mediaType === 'video') {
72928
+ // Dispose the video media
72929
+ console.debug("VideoMedia::stop - ".concat(capitalizeStr(media.mediaType), " for media ").concat(media.id, " has been stopped."));
72930
+ VideoMedia(media, xlr).stop(true);
72931
+ }
72897
72932
  }
72898
72933
  }, 1000);
72899
72934
  console.debug('startMediaTimer: Showing Media ' + media.id + ' for ' + media.duration + 's of Region ' + media.region.regionId);
@@ -74698,15 +74733,22 @@ exports.Region = Region;
74698
74733
  exports.VideoMedia = VideoMedia;
74699
74734
  exports.audioFileType = audioFileType;
74700
74735
  exports.capitalizeStr = capitalizeStr;
74736
+ exports.composeBgUrlByPlatform = composeBgUrlByPlatform;
74737
+ exports.composeMediaUrl = composeMediaUrl;
74738
+ exports.composeResourceUrl = composeResourceUrl;
74739
+ exports.composeResourceUrlByPlatform = composeResourceUrlByPlatform;
74701
74740
  exports.default = XiboLayoutRenderer;
74702
74741
  exports.defaultTrans = defaultTrans;
74703
74742
  exports.fadeInElem = fadeInElem;
74704
74743
  exports.fadeOutElem = fadeOutElem;
74705
74744
  exports.fetchJSON = fetchJSON;
74745
+ exports.fetchText = fetchText;
74706
74746
  exports.flyInElem = flyInElem;
74707
74747
  exports.flyOutElem = flyOutElem;
74708
74748
  exports.flyTransitionKeyframes = flyTransitionKeyframes;
74749
+ exports.getDataBlob = getDataBlob;
74709
74750
  exports.getFileExt = getFileExt;
74751
+ exports.getIndexByLayoutId = getIndexByLayoutId;
74710
74752
  exports.getLayout = getLayout;
74711
74753
  exports.getMediaId = getMediaId;
74712
74754
  exports.getXlf = getXlf;
@@ -74715,6 +74757,7 @@ exports.initialLayout = initialLayout;
74715
74757
  exports.initialMedia = initialMedia;
74716
74758
  exports.initialRegion = initialRegion;
74717
74759
  exports.initialXlr = initialXlr;
74760
+ exports.isEmpty = isEmpty$1;
74718
74761
  exports.nextId = nextId;
74719
74762
  exports.platform = platform;
74720
74763
  exports.preloadMediaBlob = preloadMediaBlob;