@xibosignage/xibo-layout-renderer 1.0.13 → 1.0.15

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.
@@ -72644,7 +72644,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
72644
72644
  if (vjsPlayer !== undefined) {
72645
72645
  var playerReportFault = /*#__PURE__*/function () {
72646
72646
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(msg) {
72647
- var playerSW, hasSW;
72647
+ var playerSW, hasSW, endVideo;
72648
72648
  return _regeneratorRuntime().wrap(function _callee$(_context) {
72649
72649
  while (1) switch (_context.prev = _context.next) {
72650
72650
  case 0:
@@ -72654,6 +72654,11 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
72654
72654
  return playerSW.getSW();
72655
72655
  case 3:
72656
72656
  hasSW = _context.sent;
72657
+ endVideo = function endVideo() {
72658
+ // Expire the media and dispose the video
72659
+ vjsPlayer.dispose();
72660
+ media.emitter.emit('end', media);
72661
+ };
72657
72662
  if (hasSW) {
72658
72663
  playerSW.postMsg({
72659
72664
  type: 'MEDIA_FAULT',
@@ -72666,12 +72671,12 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
72666
72671
  // Temporary setting
72667
72672
  expires: format(new Date(setExpiry(1)), 'yyyy-MM-dd HH:mm:ss')
72668
72673
  })["finally"](function () {
72669
- // Expire the media and dispose the video
72670
- vjsPlayer.dispose();
72671
- media.emitter.emit('end', media);
72674
+ endVideo();
72672
72675
  });
72676
+ } else {
72677
+ endVideo();
72673
72678
  }
72674
- case 5:
72679
+ case 6:
72675
72680
  case "end":
72676
72681
  return _context.stop();
72677
72682
  }
@@ -72689,53 +72694,91 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
72689
72694
  });
72690
72695
  vjsPlayer.on('ready', function () {
72691
72696
  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
- }
72697
+ // Race promise between a 0.5s play and a 5s skip
72698
+ Promise.race([new Promise(function (resolve, reject) {
72699
+ return setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
72700
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
72701
+ while (1) switch (_context2.prev = _context2.next) {
72702
+ case 0:
72703
+ console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Trying to force play after 0.1 seconds"));
72704
+ // Try to force play here
72705
+ _context2.prev = 1;
72706
+ _context2.next = 4;
72707
+ return vjsPlayer.play();
72708
+ case 4:
72709
+ // Resolve if play works
72710
+ resolve(true);
72711
+ _context2.next = 10;
72712
+ break;
72713
+ case 7:
72714
+ _context2.prev = 7;
72715
+ _context2.t0 = _context2["catch"](1);
72716
+ // Reject race if play fails
72717
+ reject('Play failed');
72718
+ case 10:
72719
+ case "end":
72720
+ return _context2.stop();
72721
+ }
72722
+ }, _callee2, null, [[1, 7]]);
72723
+ })), 100);
72724
+ }), new Promise(function (_, reject) {
72725
+ return setTimeout(function () {
72726
+ return reject('Timeout');
72727
+ }, 5000);
72728
+ })]).then(function () {
72729
+ console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Autoplay started"));
72730
+ })["catch"]( /*#__PURE__*/function () {
72731
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(error) {
72732
+ var _media$emitter;
72733
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
72734
+ while (1) switch (_context3.prev = _context3.next) {
72735
+ case 0:
72736
+ if (!(error === 'Timeout')) {
72737
+ _context3.next = 6;
72738
+ break;
72739
+ }
72740
+ console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Promise not resolved within 5 seconds. Move to next media"));
72741
+ vjsPlayer.dispose();
72742
+ (_media$emitter = media.emitter) === null || _media$emitter === void 0 || _media$emitter.emit('end', media);
72743
+ _context3.next = 10;
72744
+ break;
72745
+ case 6:
72746
+ console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Autoplay error: ").concat(error));
72747
+ if (!(xlr.config.platform === 'chromeOS')) {
72748
+ _context3.next = 10;
72749
+ break;
72750
+ }
72751
+ _context3.next = 10;
72752
+ return playerReportFault('Media autoplay error');
72753
+ case 10:
72754
+ case "end":
72755
+ return _context3.stop();
72756
+ }
72757
+ }, _callee3);
72758
+ }));
72759
+ return function (_x2) {
72760
+ return _ref3.apply(this, arguments);
72761
+ };
72762
+ }());
72720
72763
  });
72721
72764
  vjsPlayer.on('playing', function () {
72722
72765
  console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " is now playing . . ."));
72723
72766
  vjsPlayer.muted(media.muted);
72724
72767
  });
72725
72768
  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) {
72769
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(err) {
72770
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
72771
+ while (1) switch (_context4.prev = _context4.next) {
72729
72772
  case 0:
72730
72773
  console.debug("Media Error: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id));
72731
72774
  if (!(xlr.config.platform === 'chromeOS')) {
72732
- _context3.next = 6;
72775
+ _context4.next = 6;
72733
72776
  break;
72734
72777
  }
72735
- _context3.next = 4;
72778
+ _context4.next = 4;
72736
72779
  return playerReportFault('Video file source not supported');
72737
72780
  case 4:
72738
- _context3.next = 7;
72781
+ _context4.next = 7;
72739
72782
  break;
72740
72783
  case 6:
72741
72784
  // End media after 5 seconds
@@ -72746,18 +72789,18 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
72746
72789
  }, 5000);
72747
72790
  case 7:
72748
72791
  case "end":
72749
- return _context3.stop();
72792
+ return _context4.stop();
72750
72793
  }
72751
- }, _callee3);
72794
+ }, _callee4);
72752
72795
  }));
72753
72796
  return function (_x3) {
72754
- return _ref3.apply(this, arguments);
72797
+ return _ref4.apply(this, arguments);
72755
72798
  };
72756
72799
  }());
72757
72800
  vjsPlayer.on('ended', function () {
72758
- var _media$emitter;
72801
+ var _media$emitter2;
72759
72802
  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);
72803
+ (_media$emitter2 = media.emitter) === null || _media$emitter2 === void 0 || _media$emitter2.emit('end', media);
72761
72804
  vjsPlayer.dispose();
72762
72805
  });
72763
72806
  vjsPlayer.on('durationchange', function () {
@@ -73136,7 +73179,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
73136
73179
  $media = getNewMedia();
73137
73180
  }
73138
73181
  if (!$media) {
73139
- _context2.next = 40;
73182
+ _context2.next = 39;
73140
73183
  break;
73141
73184
  }
73142
73185
  $media.style.setProperty('display', 'block');
@@ -73165,48 +73208,46 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
73165
73208
  _context2.t3 = _context2.t2;
73166
73209
  _context2.t4 = _context2.t1.concat.call(_context2.t1, _context2.t3);
73167
73210
  _context2.t0.setProperty.call(_context2.t0, 'background-image', _context2.t4);
73168
- _context2.next = 39;
73211
+ _context2.next = 38;
73169
73212
  break;
73170
73213
  case 22:
73171
73214
  if (!(self.mediaType === 'video' && self.url !== null)) {
73172
- _context2.next = 27;
73215
+ _context2.next = 26;
73173
73216
  break;
73174
73217
  }
73175
73218
  // Initialize video.js
73176
- videojs($media, {
73219
+ self.player = videojs($media, {
73177
73220
  controls: false,
73178
73221
  preload: 'auto',
73179
73222
  autoplay: false,
73180
73223
  muted: self.muted,
73181
73224
  errorDisplay: xlr.config.platform !== 'chromeOS',
73182
- restoreEl: $media,
73183
73225
  loop: self.loop
73184
73226
  });
73185
- self.player = videojs($media);
73186
- _context2.next = 39;
73227
+ _context2.next = 38;
73187
73228
  break;
73188
- case 27:
73229
+ case 26:
73189
73230
  if (!(self.mediaType === 'audio' && self.url !== null)) {
73190
- _context2.next = 38;
73231
+ _context2.next = 37;
73191
73232
  break;
73192
73233
  }
73193
73234
  if (!isCMS) {
73194
- _context2.next = 34;
73235
+ _context2.next = 33;
73195
73236
  break;
73196
73237
  }
73197
- _context2.next = 31;
73238
+ _context2.next = 30;
73198
73239
  return preloadMediaBlob(self.url, self.mediaType);
73199
- case 31:
73240
+ case 30:
73200
73241
  _context2.t5 = _context2.sent;
73201
- _context2.next = 35;
73242
+ _context2.next = 34;
73202
73243
  break;
73203
- case 34:
73244
+ case 33:
73204
73245
  _context2.t5 = self.url;
73205
- case 35:
73246
+ case 34:
73206
73247
  $media.src = _context2.t5;
73207
- _context2.next = 39;
73248
+ _context2.next = 38;
73208
73249
  break;
73209
- case 38:
73250
+ case 37:
73210
73251
  if ((self.render === 'html' || self.mediaType === 'webpage') && self.iframe && self.checkIframeStatus) {
73211
73252
  // Set state as false ( for now )
73212
73253
  self.ready = false;
@@ -73222,9 +73263,9 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
73222
73263
  // }
73223
73264
  // });
73224
73265
  }
73225
- case 39:
73266
+ case 38:
73226
73267
  self.emitter.emit('start', self);
73227
- case 40:
73268
+ case 39:
73228
73269
  case "end":
73229
73270
  return _context2.stop();
73230
73271
  }
@@ -73286,6 +73327,9 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
73286
73327
  self.complete = false;
73287
73328
  self.ending = false;
73288
73329
  self.ended = false;
73330
+ self.curMedia = undefined;
73331
+ self.nxtMedia = undefined;
73332
+ self.currentMediaIndex = 0;
73289
73333
  self.id = props.regionId;
73290
73334
  self.uniqueId = "".concat(nextId(self.options));
73291
73335
  self.options = _objectSpread2(_objectSpread2({}, platform), props.options);
@@ -74573,9 +74617,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
74573
74617
  console.debug('prepareLayouts::xlr>layouts', self.layouts);
74574
74618
  return _context3.abrupt("return", new Promise(function (resolve) {
74575
74619
  layouts.map(function (layoutItem) {
74576
- if (!Boolean(self.layouts[layoutItem.index])) {
74577
- self.layouts[layoutItem.index] = layoutItem;
74578
- }
74620
+ self.layouts[layoutItem.index] = layoutItem;
74579
74621
  });
74580
74622
  self.currentLayoutIndex = xlrLayouts.currentLayoutIndex;
74581
74623
  self.currentLayout = self.layouts[self.currentLayoutIndex];