@xibosignage/xibo-layout-renderer 1.0.11 → 1.0.12

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.
@@ -72,6 +72,7 @@ interface IMedia {
72
72
  fileId: string;
73
73
  emitter: Emitter<IMediaEvents>;
74
74
  enableStat: boolean;
75
+ muted?: boolean;
75
76
  }
76
77
  declare const initialMedia: IMedia;
77
78
 
@@ -265,7 +266,7 @@ declare function videoFileType(str: string): string | undefined;
265
266
  declare function setExpiry(numDays: number): string;
266
267
 
267
268
  declare function VideoMedia(media: IMedia, xlr: IXlr): {
268
- init(): void;
269
+ init: () => void;
269
270
  };
270
271
 
271
272
  declare function AudioMedia(media: IMedia): {
@@ -69557,7 +69557,8 @@ var initialMedia = {
69557
69557
  return {};
69558
69558
  },
69559
69559
  emitter: {},
69560
- enableStat: false
69560
+ enableStat: false,
69561
+ muted: false
69561
69562
  };
69562
69563
 
69563
69564
  /*
@@ -72624,15 +72625,15 @@ function composeVideoSource(_x, _x2) {
72624
72625
  return _composeVideoSource.apply(this, arguments);
72625
72626
  }
72626
72627
  function _composeVideoSource() {
72627
- _composeVideoSource = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2($media, media) {
72628
+ _composeVideoSource = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4($media, media) {
72628
72629
  var videoSrc, vidType, $videoSource;
72629
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
72630
- while (1) switch (_context2.prev = _context2.next) {
72630
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
72631
+ while (1) switch (_context4.prev = _context4.next) {
72631
72632
  case 0:
72632
- _context2.next = 2;
72633
+ _context4.next = 2;
72633
72634
  return preloadMediaBlob(media.url, media.mediaType);
72634
72635
  case 2:
72635
- videoSrc = _context2.sent;
72636
+ videoSrc = _context4.sent;
72636
72637
  vidType = videoFileType(getFileExt(media.uri)); // Only add one source per type
72637
72638
  if ($media.querySelectorAll("source[type=\"".concat(vidType, "\"]")).length === 0) {
72638
72639
  $videoSource = document.createElement('source');
@@ -72640,12 +72641,12 @@ function _composeVideoSource() {
72640
72641
  $videoSource.type = vidType;
72641
72642
  $media.insertBefore($videoSource, $media.lastElementChild);
72642
72643
  }
72643
- return _context2.abrupt("return", $media);
72644
+ return _context4.abrupt("return", $media);
72644
72645
  case 6:
72645
72646
  case "end":
72646
- return _context2.stop();
72647
+ return _context4.stop();
72647
72648
  }
72648
- }, _callee2);
72649
+ }, _callee4);
72649
72650
  }));
72650
72651
  return _composeVideoSource.apply(this, arguments);
72651
72652
  }
@@ -72655,87 +72656,130 @@ function VideoMedia(media, xlr) {
72655
72656
  var $videoMedia = document.getElementById(getMediaId(media));
72656
72657
  if ($videoMedia) {
72657
72658
  var vjsPlayer = videojs.getPlayer($videoMedia);
72658
- vjsPlayer === null || vjsPlayer === void 0 || vjsPlayer.on('loadstart', function () {
72659
- console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has started loading data . . ."));
72660
- });
72661
- vjsPlayer === null || vjsPlayer === void 0 || vjsPlayer.on('loadstart', function () {
72662
- if ($videoMedia.readyState >= 2) {
72663
- console.debug("".concat(capitalizeStr(media.mediaType), " data for media > ").concat(media.id, " has been fully loaded . . ."));
72664
- }
72665
- });
72666
- vjsPlayer === null || vjsPlayer === void 0 || vjsPlayer.on('canplay', function () {
72667
- console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " can be played . . ."));
72668
- // Autoplay restarted
72669
- console.debug('autoplay started . . .');
72670
- vjsPlayer.muted(true);
72671
- vjsPlayer.play();
72672
- });
72673
- vjsPlayer === null || vjsPlayer === void 0 || vjsPlayer.on('playing', function () {
72674
- console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " is now playing . . ."));
72675
- });
72676
- vjsPlayer === null || vjsPlayer === void 0 || vjsPlayer.on('error', /*#__PURE__*/function () {
72677
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(err) {
72678
- var playerSW, hasSW;
72679
- return _regeneratorRuntime().wrap(function _callee$(_context) {
72680
- while (1) switch (_context.prev = _context.next) {
72681
- case 0:
72682
- console.debug("Media Error: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id));
72683
- if (!(xlr.config.platform === 'chromeOS')) {
72684
- _context.next = 9;
72685
- break;
72686
- }
72687
- // Immediately expire media and report a fault
72688
- playerSW = PwaSW();
72689
- _context.next = 5;
72690
- return playerSW.getSW();
72691
- case 5:
72692
- hasSW = _context.sent;
72693
- if (hasSW) {
72694
- playerSW.postMsg({
72695
- type: 'MEDIA_FAULT',
72696
- code: 5002,
72697
- reason: 'Video file source not supported',
72698
- mediaId: media.id,
72699
- regionId: media.region.id,
72700
- layoutId: media.region.layout.id,
72701
- date: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
72702
- // Temporary setting
72703
- expires: format(new Date(setExpiry(7)), 'yyyy-MM-dd HH:mm:ss')
72704
- })["finally"](function () {
72705
- // Expire the media and dispose the video
72706
- vjsPlayer.dispose();
72707
- media.emitter.emit('end', media);
72708
- });
72709
- }
72710
- _context.next = 10;
72711
- break;
72712
- case 9:
72713
- // End media after 5 seconds
72714
- setTimeout(function () {
72715
- console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has ended . . ."));
72716
- media.emitter.emit('end', media);
72717
- vjsPlayer.dispose();
72718
- }, 5000);
72719
- case 10:
72720
- case "end":
72721
- return _context.stop();
72722
- }
72723
- }, _callee);
72724
- }));
72725
- return function (_x3) {
72726
- return _ref.apply(this, arguments);
72727
- };
72728
- }());
72729
- if (media.duration === 0) {
72730
- vjsPlayer === null || vjsPlayer === void 0 || vjsPlayer.on('durationchange', function () {
72731
- console.debug('Showing Media ' + media.id + ' for ' + vjsPlayer.duration() + 's of Region ' + media.region.regionId);
72659
+ if (vjsPlayer !== undefined) {
72660
+ var playerReportFault = /*#__PURE__*/function () {
72661
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(msg) {
72662
+ var playerSW, hasSW;
72663
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
72664
+ while (1) switch (_context.prev = _context.next) {
72665
+ case 0:
72666
+ // Immediately expire media and report a fault
72667
+ playerSW = PwaSW();
72668
+ _context.next = 3;
72669
+ return playerSW.getSW();
72670
+ case 3:
72671
+ hasSW = _context.sent;
72672
+ if (hasSW) {
72673
+ playerSW.postMsg({
72674
+ type: 'MEDIA_FAULT',
72675
+ code: 5002,
72676
+ reason: msg,
72677
+ mediaId: media.id,
72678
+ regionId: media.region.id,
72679
+ layoutId: media.region.layout.id,
72680
+ date: format(new Date(), 'yyyy-MM-dd HH:mm:ss'),
72681
+ // Temporary setting
72682
+ expires: format(new Date(setExpiry(1)), 'yyyy-MM-dd HH:mm:ss')
72683
+ })["finally"](function () {
72684
+ // Expire the media and dispose the video
72685
+ vjsPlayer.dispose();
72686
+ media.emitter.emit('end', media);
72687
+ });
72688
+ }
72689
+ case 5:
72690
+ case "end":
72691
+ return _context.stop();
72692
+ }
72693
+ }, _callee);
72694
+ }));
72695
+ return function playerReportFault(_x3) {
72696
+ return _ref.apply(this, arguments);
72697
+ };
72698
+ }();
72699
+ vjsPlayer.on('loadstart', function () {
72700
+ console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has started loading data . . ."));
72732
72701
  });
72733
- vjsPlayer === null || vjsPlayer === void 0 || vjsPlayer.on('ended', function () {
72734
- var _media$emitter;
72735
- console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has ended playing . . ."));
72736
- (_media$emitter = media.emitter) === null || _media$emitter === void 0 || _media$emitter.emit('end', media);
72737
- vjsPlayer.dispose();
72702
+ vjsPlayer.on('canplay', function () {
72703
+ console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " can be played . . ."));
72738
72704
  });
72705
+ vjsPlayer.ready(function () {
72706
+ var promise = vjsPlayer.play();
72707
+ if (promise !== undefined) {
72708
+ promise.then(function () {
72709
+ // Autoplay restarted
72710
+ console.debug('autoplay started . . .');
72711
+ vjsPlayer.muted(true);
72712
+ })["catch"]( /*#__PURE__*/function () {
72713
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(error) {
72714
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
72715
+ while (1) switch (_context2.prev = _context2.next) {
72716
+ case 0:
72717
+ console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " autoplay error"));
72718
+ if (!(xlr.config.platform === 'chromeOS')) {
72719
+ _context2.next = 4;
72720
+ break;
72721
+ }
72722
+ _context2.next = 4;
72723
+ return playerReportFault('Media autoplay error');
72724
+ case 4:
72725
+ case "end":
72726
+ return _context2.stop();
72727
+ }
72728
+ }, _callee2);
72729
+ }));
72730
+ return function (_x4) {
72731
+ return _ref2.apply(this, arguments);
72732
+ };
72733
+ }());
72734
+ }
72735
+ });
72736
+ vjsPlayer.on('playing', function () {
72737
+ console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " is now playing . . ."));
72738
+ vjsPlayer.muted(media.muted);
72739
+ });
72740
+ vjsPlayer.on('error', /*#__PURE__*/function () {
72741
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(err) {
72742
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
72743
+ while (1) switch (_context3.prev = _context3.next) {
72744
+ case 0:
72745
+ console.debug("Media Error: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id));
72746
+ if (!(xlr.config.platform === 'chromeOS')) {
72747
+ _context3.next = 6;
72748
+ break;
72749
+ }
72750
+ _context3.next = 4;
72751
+ return playerReportFault('Video file source not supported');
72752
+ case 4:
72753
+ _context3.next = 7;
72754
+ break;
72755
+ case 6:
72756
+ // End media after 5 seconds
72757
+ setTimeout(function () {
72758
+ console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has ended . . ."));
72759
+ media.emitter.emit('end', media);
72760
+ vjsPlayer.dispose();
72761
+ }, 5000);
72762
+ case 7:
72763
+ case "end":
72764
+ return _context3.stop();
72765
+ }
72766
+ }, _callee3);
72767
+ }));
72768
+ return function (_x5) {
72769
+ return _ref3.apply(this, arguments);
72770
+ };
72771
+ }());
72772
+ if (media.duration === 0) {
72773
+ vjsPlayer.on('durationchange', function () {
72774
+ console.debug('Showing Media ' + media.id + ' for ' + vjsPlayer.duration() + 's of Region ' + media.region.regionId);
72775
+ });
72776
+ vjsPlayer.on('ended', function () {
72777
+ var _media$emitter;
72778
+ console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has ended playing . . ."));
72779
+ vjsPlayer.dispose();
72780
+ (_media$emitter = media.emitter) === null || _media$emitter === void 0 || _media$emitter.emit('end', media);
72781
+ });
72782
+ }
72739
72783
  }
72740
72784
  }
72741
72785
  }
@@ -72948,7 +72992,7 @@ function Media(region, mediaId, xml, options, xlr) {
72948
72992
  tmpUrl = composeResourceUrlByPlatform(xlr.config, resourceUrlParams);
72949
72993
  } else if (xlr.config.platform === 'chromeOS') {
72950
72994
  tmpUrl = composeResourceUrl(xlr.config, resourceUrlParams);
72951
- if (self.mediaType === 'image' || self.mediaType === 'video') {
72995
+ if (self.mediaType === 'image' || self.mediaType === 'video' || self.mediaType === 'audio') {
72952
72996
  tmpUrl = composeMediaUrl(resourceUrlParams);
72953
72997
  }
72954
72998
  }
@@ -73099,7 +73143,7 @@ function Media(region, mediaId, xml, options, xlr) {
73099
73143
  $media = getNewMedia();
73100
73144
  }
73101
73145
  if (!$media) {
73102
- _context2.next = 44;
73146
+ _context2.next = 45;
73103
73147
  break;
73104
73148
  }
73105
73149
  $media.style.setProperty('display', 'block');
@@ -73128,11 +73172,11 @@ function Media(region, mediaId, xml, options, xlr) {
73128
73172
  _context2.t3 = _context2.t2;
73129
73173
  _context2.t4 = _context2.t1.concat.call(_context2.t1, _context2.t3);
73130
73174
  _context2.t0.setProperty.call(_context2.t0, 'background-image', _context2.t4);
73131
- _context2.next = 43;
73175
+ _context2.next = 44;
73132
73176
  break;
73133
73177
  case 22:
73134
73178
  if (!(self.mediaType === 'video' && self.url !== null)) {
73135
- _context2.next = 31;
73179
+ _context2.next = 32;
73136
73180
  break;
73137
73181
  }
73138
73182
  _context2.next = 25;
@@ -73143,37 +73187,39 @@ function Media(region, mediaId, xml, options, xlr) {
73143
73187
  if (Boolean(self.options['mute'])) {
73144
73188
  isMuted = self.options.mute === '1';
73145
73189
  }
73190
+ self.muted = isMuted;
73146
73191
  videojs($media, {
73147
73192
  controls: false,
73148
73193
  preload: 'auto',
73149
73194
  autoplay: false,
73150
73195
  muted: isMuted,
73151
- errorDisplay: xlr.config.platform !== 'chromeOS'
73196
+ errorDisplay: xlr.config.platform !== 'chromeOS',
73197
+ restoreEl: $media
73152
73198
  });
73153
- _context2.next = 43;
73199
+ _context2.next = 44;
73154
73200
  break;
73155
- case 31:
73201
+ case 32:
73156
73202
  if (!(self.mediaType === 'audio' && self.url !== null)) {
73157
- _context2.next = 42;
73203
+ _context2.next = 43;
73158
73204
  break;
73159
73205
  }
73160
73206
  if (!isCMS) {
73161
- _context2.next = 38;
73207
+ _context2.next = 39;
73162
73208
  break;
73163
73209
  }
73164
- _context2.next = 35;
73210
+ _context2.next = 36;
73165
73211
  return preloadMediaBlob(self.url, self.mediaType);
73166
- case 35:
73212
+ case 36:
73167
73213
  _context2.t5 = _context2.sent;
73168
- _context2.next = 39;
73214
+ _context2.next = 40;
73169
73215
  break;
73170
- case 38:
73171
- _context2.t5 = self.url;
73172
73216
  case 39:
73217
+ _context2.t5 = self.url;
73218
+ case 40:
73173
73219
  $media.src = _context2.t5;
73174
- _context2.next = 43;
73220
+ _context2.next = 44;
73175
73221
  break;
73176
- case 42:
73222
+ case 43:
73177
73223
  if ((self.render === 'html' || self.mediaType === 'webpage') && self.iframe && self.checkIframeStatus) {
73178
73224
  // Set state as false ( for now )
73179
73225
  self.ready = false;
@@ -73189,9 +73235,9 @@ function Media(region, mediaId, xml, options, xlr) {
73189
73235
  // }
73190
73236
  // });
73191
73237
  }
73192
- case 43:
73193
- self.emitter.emit('start', self);
73194
73238
  case 44:
73239
+ self.emitter.emit('start', self);
73240
+ case 45:
73195
73241
  case "end":
73196
73242
  return _context2.stop();
73197
73243
  }