@xibosignage/xibo-layout-renderer 1.0.11 → 1.0.13

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.
@@ -69560,7 +69560,9 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
69560
69560
  return {};
69561
69561
  },
69562
69562
  emitter: {},
69563
- enableStat: false
69563
+ enableStat: false,
69564
+ muted: false,
69565
+ player: undefined
69564
69566
  };
69565
69567
 
69566
69568
  /*
@@ -72623,123 +72625,149 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
72623
72625
  };
72624
72626
  }
72625
72627
 
72626
- function composeVideoSource(_x, _x2) {
72627
- return _composeVideoSource.apply(this, arguments);
72628
- }
72629
- function _composeVideoSource() {
72630
- _composeVideoSource = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2($media, media) {
72631
- var videoSrc, vidType, $videoSource;
72632
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
72633
- while (1) switch (_context2.prev = _context2.next) {
72634
- case 0:
72635
- _context2.next = 2;
72636
- return preloadMediaBlob(media.url, media.mediaType);
72637
- case 2:
72638
- videoSrc = _context2.sent;
72639
- vidType = videoFileType(getFileExt(media.uri)); // Only add one source per type
72640
- if ($media.querySelectorAll("source[type=\"".concat(vidType, "\"]")).length === 0) {
72641
- $videoSource = document.createElement('source');
72642
- $videoSource.src = videoSrc;
72643
- $videoSource.type = vidType;
72644
- $media.insertBefore($videoSource, $media.lastElementChild);
72645
- }
72646
- return _context2.abrupt("return", $media);
72647
- case 6:
72648
- case "end":
72649
- return _context2.stop();
72650
- }
72651
- }, _callee2);
72652
- }));
72653
- return _composeVideoSource.apply(this, arguments);
72628
+ function composeVideoSource($media, media) {
72629
+ // const videoSrc = await preloadMediaBlob(media.url as string, media.mediaType as MediaTypes);
72630
+ var vidType = videoFileType(getFileExt(media.uri));
72631
+ // Only add one source per type
72632
+ if ($media.querySelectorAll("source[type=\"".concat(vidType, "\"]")).length === 0) {
72633
+ var $videoSource = document.createElement('source');
72634
+ $videoSource.src = media.url;
72635
+ $videoSource.type = vidType;
72636
+ $media.insertBefore($videoSource, $media.lastElementChild);
72637
+ }
72638
+ return $media;
72654
72639
  }
72655
72640
  function VideoMedia(media, xlr) {
72656
72641
  return {
72657
72642
  init: function init() {
72658
- var $videoMedia = document.getElementById(getMediaId(media));
72659
- if ($videoMedia) {
72660
- var vjsPlayer = videojs.getPlayer($videoMedia);
72661
- vjsPlayer === null || vjsPlayer === void 0 || vjsPlayer.on('loadstart', function () {
72662
- console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has started loading data . . ."));
72663
- });
72664
- vjsPlayer === null || vjsPlayer === void 0 || vjsPlayer.on('loadstart', function () {
72665
- if ($videoMedia.readyState >= 2) {
72666
- console.debug("".concat(capitalizeStr(media.mediaType), " data for media > ").concat(media.id, " has been fully loaded . . ."));
72667
- }
72668
- });
72669
- vjsPlayer === null || vjsPlayer === void 0 || vjsPlayer.on('canplay', function () {
72670
- console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " can be played . . ."));
72671
- // Autoplay restarted
72672
- console.debug('autoplay started . . .');
72673
- vjsPlayer.muted(true);
72674
- vjsPlayer.play();
72675
- });
72676
- vjsPlayer === null || vjsPlayer === void 0 || vjsPlayer.on('playing', function () {
72677
- console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " is now playing . . ."));
72678
- });
72679
- vjsPlayer === null || vjsPlayer === void 0 || vjsPlayer.on('error', /*#__PURE__*/function () {
72680
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(err) {
72643
+ var vjsPlayer = media.player;
72644
+ if (vjsPlayer !== undefined) {
72645
+ var playerReportFault = /*#__PURE__*/function () {
72646
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(msg) {
72681
72647
  var playerSW, hasSW;
72682
72648
  return _regeneratorRuntime().wrap(function _callee$(_context) {
72683
72649
  while (1) switch (_context.prev = _context.next) {
72684
72650
  case 0:
72685
- console.debug("Media Error: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id));
72686
- if (!(xlr.config.platform === 'chromeOS')) {
72687
- _context.next = 9;
72688
- break;
72689
- }
72690
72651
  // Immediately expire media and report a fault
72691
72652
  playerSW = PwaSW();
72692
- _context.next = 5;
72653
+ _context.next = 3;
72693
72654
  return playerSW.getSW();
72694
- case 5:
72655
+ case 3:
72695
72656
  hasSW = _context.sent;
72696
72657
  if (hasSW) {
72697
72658
  playerSW.postMsg({
72698
72659
  type: 'MEDIA_FAULT',
72699
72660
  code: 5002,
72700
- reason: 'Video file source not supported',
72661
+ reason: msg,
72701
72662
  mediaId: media.id,
72702
72663
  regionId: media.region.id,
72703
72664
  layoutId: media.region.layout.id,
72704
72665
  date: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
72705
72666
  // Temporary setting
72706
- expires: format(new Date(setExpiry(7)), 'yyyy-MM-dd HH:mm:ss')
72667
+ expires: format(new Date(setExpiry(1)), 'yyyy-MM-dd HH:mm:ss')
72707
72668
  })["finally"](function () {
72708
72669
  // Expire the media and dispose the video
72709
72670
  vjsPlayer.dispose();
72710
72671
  media.emitter.emit('end', media);
72711
72672
  });
72712
72673
  }
72713
- _context.next = 10;
72674
+ case 5:
72675
+ case "end":
72676
+ return _context.stop();
72677
+ }
72678
+ }, _callee);
72679
+ }));
72680
+ return function playerReportFault(_x) {
72681
+ return _ref.apply(this, arguments);
72682
+ };
72683
+ }();
72684
+ vjsPlayer.on('loadstart', function () {
72685
+ console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has started loading data . . ."));
72686
+ });
72687
+ vjsPlayer.on('canplay', function () {
72688
+ console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " can be played . . ."));
72689
+ });
72690
+ vjsPlayer.on('ready', function () {
72691
+ vjsPlayer.muted(true);
72692
+ var promise = vjsPlayer.play();
72693
+ if (promise !== undefined) {
72694
+ promise.then(function () {
72695
+ // Autoplay restarted
72696
+ console.debug('autoplay started . . .');
72697
+ })["catch"]( /*#__PURE__*/function () {
72698
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(error) {
72699
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
72700
+ while (1) switch (_context2.prev = _context2.next) {
72701
+ case 0:
72702
+ console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " autoplay error"));
72703
+ if (!(xlr.config.platform === 'chromeOS')) {
72704
+ _context2.next = 4;
72705
+ break;
72706
+ }
72707
+ _context2.next = 4;
72708
+ return playerReportFault('Media autoplay error');
72709
+ case 4:
72710
+ case "end":
72711
+ return _context2.stop();
72712
+ }
72713
+ }, _callee2);
72714
+ }));
72715
+ return function (_x2) {
72716
+ return _ref2.apply(this, arguments);
72717
+ };
72718
+ }());
72719
+ }
72720
+ });
72721
+ vjsPlayer.on('playing', function () {
72722
+ console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " is now playing . . ."));
72723
+ vjsPlayer.muted(media.muted);
72724
+ });
72725
+ vjsPlayer.on('error', /*#__PURE__*/function () {
72726
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(err) {
72727
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
72728
+ while (1) switch (_context3.prev = _context3.next) {
72729
+ case 0:
72730
+ console.debug("Media Error: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id));
72731
+ if (!(xlr.config.platform === 'chromeOS')) {
72732
+ _context3.next = 6;
72733
+ break;
72734
+ }
72735
+ _context3.next = 4;
72736
+ return playerReportFault('Video file source not supported');
72737
+ case 4:
72738
+ _context3.next = 7;
72714
72739
  break;
72715
- case 9:
72740
+ case 6:
72716
72741
  // End media after 5 seconds
72717
72742
  setTimeout(function () {
72718
72743
  console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has ended . . ."));
72719
72744
  media.emitter.emit('end', media);
72720
72745
  vjsPlayer.dispose();
72721
72746
  }, 5000);
72722
- case 10:
72747
+ case 7:
72723
72748
  case "end":
72724
- return _context.stop();
72749
+ return _context3.stop();
72725
72750
  }
72726
- }, _callee);
72751
+ }, _callee3);
72727
72752
  }));
72728
72753
  return function (_x3) {
72729
- return _ref.apply(this, arguments);
72754
+ return _ref3.apply(this, arguments);
72730
72755
  };
72731
72756
  }());
72732
- if (media.duration === 0) {
72733
- vjsPlayer === null || vjsPlayer === void 0 || vjsPlayer.on('durationchange', function () {
72734
- console.debug('Showing Media ' + media.id + ' for ' + vjsPlayer.duration() + 's of Region ' + media.region.regionId);
72735
- });
72736
- vjsPlayer === null || vjsPlayer === void 0 || vjsPlayer.on('ended', function () {
72737
- var _media$emitter;
72738
- console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has ended playing . . ."));
72739
- (_media$emitter = media.emitter) === null || _media$emitter === void 0 || _media$emitter.emit('end', media);
72740
- vjsPlayer.dispose();
72741
- });
72742
- }
72757
+ vjsPlayer.on('ended', function () {
72758
+ var _media$emitter;
72759
+ console.debug("VideoMedia: onended: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has ended playing . . ."));
72760
+ (_media$emitter = media.emitter) === null || _media$emitter === void 0 || _media$emitter.emit('end', media);
72761
+ vjsPlayer.dispose();
72762
+ });
72763
+ vjsPlayer.on('durationchange', function () {
72764
+ if (media.duration === 0 && vjsPlayer.duration() !== undefined) {
72765
+ media.duration = vjsPlayer.duration();
72766
+ } else if (media.duration > 0) {
72767
+ vjsPlayer.duration(media.duration);
72768
+ }
72769
+ console.debug('VIDEOJS: ondurationchange: Showing Media ' + media.id + ' for ' + vjsPlayer.duration() + 's of Region ' + media.region.regionId);
72770
+ });
72743
72771
  }
72744
72772
  }
72745
72773
  };
@@ -72820,10 +72848,11 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
72820
72848
  mediaTimer = setInterval(function () {
72821
72849
  mediaTimeCount++;
72822
72850
  if (mediaTimeCount > media.duration) {
72851
+ console.debug('startMediaTimer: emit>end: on media ' + media.id + ' of Region ' + media.region.regionId);
72823
72852
  media.emitter.emit('end', media);
72824
72853
  }
72825
72854
  }, 1000);
72826
- console.debug('Showing Media ' + media.id + ' for ' + media.duration + 's of Region ' + media.region.regionId);
72855
+ console.debug('startMediaTimer: Showing Media ' + media.id + ' for ' + media.duration + 's of Region ' + media.region.regionId);
72827
72856
  };
72828
72857
  emitter.on('start', function (media) {
72829
72858
  if (media.mediaType === 'video') {
@@ -72951,7 +72980,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
72951
72980
  tmpUrl = composeResourceUrlByPlatform(xlr.config, resourceUrlParams);
72952
72981
  } else if (xlr.config.platform === 'chromeOS') {
72953
72982
  tmpUrl = composeResourceUrl(xlr.config, resourceUrlParams);
72954
- if (self.mediaType === 'image' || self.mediaType === 'video') {
72983
+ if (self.mediaType === 'image' || self.mediaType === 'video' || self.mediaType === 'audio') {
72955
72984
  tmpUrl = composeMediaUrl(resourceUrlParams);
72956
72985
  }
72957
72986
  }
@@ -72978,8 +73007,11 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
72978
73007
  $media.style.cssText = $media.style.cssText.concat("background-position: ".concat(align, " ").concat(valign));
72979
73008
  }
72980
73009
  } else if (self.mediaType === 'video') {
72981
- var $videoMedia = $media;
72982
- $videoMedia.textContent = 'Unsupported Video';
73010
+ var $videoMedia = composeVideoSource($media, self);
73011
+ var isMuted = false;
73012
+ if (Boolean(self.options['mute'])) {
73013
+ isMuted = self.options.mute === '1';
73014
+ }
72983
73015
  if (Boolean(self.options['scaletype'])) {
72984
73016
  if (self.options.scaletype === 'stretch') {
72985
73017
  $videoMedia.style.objectFit = 'fill';
@@ -72987,8 +73019,10 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
72987
73019
  }
72988
73020
  $videoMedia.classList.add('video-js', 'vjs-default-skin');
72989
73021
  if (self.loop) {
73022
+ self.loop = true;
72990
73023
  $videoMedia.loop = true;
72991
73024
  }
73025
+ self.muted = isMuted;
72992
73026
  $media = $videoMedia;
72993
73027
  } else if (self.mediaType === 'audio') {
72994
73028
  var $audioMedia = $media;
@@ -73091,7 +73125,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
73091
73125
  }
73092
73126
  var showCurrentMedia = /*#__PURE__*/function () {
73093
73127
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
73094
- var $mediaId, $media, isCMS, isMuted;
73128
+ var $mediaId, $media, isCMS;
73095
73129
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
73096
73130
  while (1) switch (_context2.prev = _context2.next) {
73097
73131
  case 0:
@@ -73102,7 +73136,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
73102
73136
  $media = getNewMedia();
73103
73137
  }
73104
73138
  if (!$media) {
73105
- _context2.next = 44;
73139
+ _context2.next = 40;
73106
73140
  break;
73107
73141
  }
73108
73142
  $media.style.setProperty('display', 'block');
@@ -73131,52 +73165,48 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
73131
73165
  _context2.t3 = _context2.t2;
73132
73166
  _context2.t4 = _context2.t1.concat.call(_context2.t1, _context2.t3);
73133
73167
  _context2.t0.setProperty.call(_context2.t0, 'background-image', _context2.t4);
73134
- _context2.next = 43;
73168
+ _context2.next = 39;
73135
73169
  break;
73136
73170
  case 22:
73137
73171
  if (!(self.mediaType === 'video' && self.url !== null)) {
73138
- _context2.next = 31;
73172
+ _context2.next = 27;
73139
73173
  break;
73140
73174
  }
73141
- _context2.next = 25;
73142
- return composeVideoSource($media, self);
73143
- case 25:
73144
- $media = _context2.sent;
73145
- isMuted = false;
73146
- if (Boolean(self.options['mute'])) {
73147
- isMuted = self.options.mute === '1';
73148
- }
73175
+ // Initialize video.js
73149
73176
  videojs($media, {
73150
73177
  controls: false,
73151
73178
  preload: 'auto',
73152
73179
  autoplay: false,
73153
- muted: isMuted,
73154
- errorDisplay: xlr.config.platform !== 'chromeOS'
73180
+ muted: self.muted,
73181
+ errorDisplay: xlr.config.platform !== 'chromeOS',
73182
+ restoreEl: $media,
73183
+ loop: self.loop
73155
73184
  });
73156
- _context2.next = 43;
73185
+ self.player = videojs($media);
73186
+ _context2.next = 39;
73157
73187
  break;
73158
- case 31:
73188
+ case 27:
73159
73189
  if (!(self.mediaType === 'audio' && self.url !== null)) {
73160
- _context2.next = 42;
73190
+ _context2.next = 38;
73161
73191
  break;
73162
73192
  }
73163
73193
  if (!isCMS) {
73164
- _context2.next = 38;
73194
+ _context2.next = 34;
73165
73195
  break;
73166
73196
  }
73167
- _context2.next = 35;
73197
+ _context2.next = 31;
73168
73198
  return preloadMediaBlob(self.url, self.mediaType);
73169
- case 35:
73199
+ case 31:
73170
73200
  _context2.t5 = _context2.sent;
73171
- _context2.next = 39;
73201
+ _context2.next = 35;
73172
73202
  break;
73173
- case 38:
73203
+ case 34:
73174
73204
  _context2.t5 = self.url;
73175
- case 39:
73205
+ case 35:
73176
73206
  $media.src = _context2.t5;
73177
- _context2.next = 43;
73207
+ _context2.next = 39;
73178
73208
  break;
73179
- case 42:
73209
+ case 38:
73180
73210
  if ((self.render === 'html' || self.mediaType === 'webpage') && self.iframe && self.checkIframeStatus) {
73181
73211
  // Set state as false ( for now )
73182
73212
  self.ready = false;
@@ -73192,9 +73222,9 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
73192
73222
  // }
73193
73223
  // });
73194
73224
  }
73195
- case 43:
73225
+ case 39:
73196
73226
  self.emitter.emit('start', self);
73197
- case 44:
73227
+ case 40:
73198
73228
  case "end":
73199
73229
  return _context2.stop();
73200
73230
  }
@@ -73319,7 +73349,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
73319
73349
  console.debug('Region::finished called . . . ', self.id);
73320
73350
  // Mark as complete
73321
73351
  self.complete = true;
73322
- self.layout.regions[regionObject.index] = regionObject;
73352
+ self.layout.regions[regionObject.index] = self;
73323
73353
  self.layout.regionExpired();
73324
73354
  };
73325
73355
  regionObject.prepareMediaObjects = function () {
@@ -73441,7 +73471,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
73441
73471
  }
73442
73472
  };
73443
73473
  regionObject.playNextMedia = function () {
73444
- var _self$curMedia, _self$curMedia2, _self$curMedia3, _self$curMedia4;
73474
+ var _self$curMedia, _self$curMedia2, _self$curMedia3, _self$curMedia4, _self$curMedia5;
73445
73475
  var self = regionObject;
73446
73476
  /* The current media has finished running */
73447
73477
  if (self.ended) {
@@ -73461,7 +73491,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
73461
73491
  // When the region has completed and mediaObjects.length = 1
73462
73492
  // and curMedia.loop = false, then put the media on
73463
73493
  // its current state
73464
- if (self.complete && self.mediaObjects.length === 1 && ((_self$curMedia2 = self.curMedia) === null || _self$curMedia2 === void 0 ? void 0 : _self$curMedia2.render) !== 'html' && ((_self$curMedia3 = self.curMedia) === null || _self$curMedia3 === void 0 ? void 0 : _self$curMedia3.mediaType) === 'image' && !((_self$curMedia4 = self.curMedia) !== null && _self$curMedia4 !== void 0 && _self$curMedia4.loop)) {
73494
+ if (self.complete && self.mediaObjects.length === 1 && ((_self$curMedia2 = self.curMedia) === null || _self$curMedia2 === void 0 ? void 0 : _self$curMedia2.render) !== 'html' && (((_self$curMedia3 = self.curMedia) === null || _self$curMedia3 === void 0 ? void 0 : _self$curMedia3.mediaType) === 'image' || ((_self$curMedia4 = self.curMedia) === null || _self$curMedia4 === void 0 ? void 0 : _self$curMedia4.mediaType) === 'video') && !((_self$curMedia5 = self.curMedia) !== null && _self$curMedia5 !== void 0 && _self$curMedia5.loop)) {
73465
73495
  return;
73466
73496
  }
73467
73497
  self.currentMediaIndex = self.currentMediaIndex + 1;