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