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