@xibosignage/xibo-layout-renderer 1.0.16 → 1.0.17

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.
@@ -285,6 +285,7 @@ declare function isEmpty(input: any): boolean;
285
285
  declare function setExpiry(numDays: number): string;
286
286
 
287
287
  declare function VideoMedia(media: IMedia, xlr: IXlr): {
288
+ duration: number;
288
289
  init: () => void;
289
290
  stop: (disposeOnly?: boolean) => void;
290
291
  };
@@ -72666,9 +72666,12 @@ function composeVideoSource($media, media) {
72666
72666
  return $media;
72667
72667
  }
72668
72668
  function VideoMedia(media, xlr) {
72669
- var videoMediaInstance = {
72669
+ return {
72670
+ duration: 0,
72670
72671
  init: function init() {
72672
+ var _this = this;
72671
72673
  var vjsPlayer = media.player;
72674
+ this.duration = media.duration;
72672
72675
  if (vjsPlayer !== undefined) {
72673
72676
  var playerReportFault = /*#__PURE__*/function () {
72674
72677
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(msg) {
@@ -72694,10 +72697,10 @@ function VideoMedia(media, xlr) {
72694
72697
  // Temporary setting
72695
72698
  expires: format(new Date(setExpiry(1)), 'yyyy-MM-dd HH:mm:ss')
72696
72699
  })["finally"](function () {
72697
- videoMediaInstance.stop();
72700
+ _this.stop();
72698
72701
  });
72699
72702
  } else {
72700
- videoMediaInstance.stop();
72703
+ _this.stop();
72701
72704
  }
72702
72705
  case 5:
72703
72706
  case "end":
@@ -72710,11 +72713,26 @@ function VideoMedia(media, xlr) {
72710
72713
  };
72711
72714
  }();
72712
72715
  vjsPlayer.on('loadstart', function () {
72713
- console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has started loading data . . ."));
72716
+ console.debug("VideoMedia: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has started loading data . . ."));
72714
72717
  });
72715
- vjsPlayer.on('canplay', function () {
72716
- console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " can be played . . ."));
72718
+ vjsPlayer.one('loadedmetadata', function () {
72719
+ if (media.duration === 0) {
72720
+ _this.duration = vjsPlayer.duration();
72721
+ }
72722
+ console.debug('VideoMedia: loadedmetadata: Setting video duration to = ' + _this.duration);
72723
+ });
72724
+ vjsPlayer.one('canplay', function () {
72725
+ console.debug("VideoMedia: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " can be played . . ."));
72717
72726
  });
72727
+ vjsPlayer.one('playing', function () {
72728
+ console.debug('VideoMedia: playing: Showing Media ' + media.id + ' for ' + _this.duration + 's of Region ' + media.region.regionId);
72729
+ console.debug("VideoMedia: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " is now playing . . ."));
72730
+ });
72731
+ // @NOTE: When video is paused due to fail in unmuting the video
72732
+ // and video has media.duration = 0, the video will stay paused and the video cycle won't end
72733
+ // @TODO: Add timer when video is paused due to unmuting fail and duration that is equal to 0
72734
+ // @NOTE: The pause issue when unmuting the video is mainly on a browser level.
72735
+ // Please visit https://developer.chrome.com/blog/autoplay/ for more info.
72718
72736
  vjsPlayer.on('ready', function () {
72719
72737
  vjsPlayer.muted(true);
72720
72738
  // Race promise between a 0.5s play and a 5s skip
@@ -72723,33 +72741,35 @@ function VideoMedia(media, xlr) {
72723
72741
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
72724
72742
  while (1) switch (_context2.prev = _context2.next) {
72725
72743
  case 0:
72726
- console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Trying to force play after 0.1 seconds"));
72744
+ console.debug("VideoMedia: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Trying to force play after 0.1 seconds"));
72727
72745
  // Try to force play here
72728
72746
  _context2.prev = 1;
72729
- _context2.next = 4;
72747
+ // Set video mute/unmute based on setting once playing
72748
+ vjsPlayer.muted(media.muted);
72749
+ _context2.next = 5;
72730
72750
  return vjsPlayer.play();
72731
- case 4:
72751
+ case 5:
72732
72752
  // Resolve if play works
72733
72753
  resolve(true);
72734
- _context2.next = 10;
72754
+ _context2.next = 11;
72735
72755
  break;
72736
- case 7:
72737
- _context2.prev = 7;
72756
+ case 8:
72757
+ _context2.prev = 8;
72738
72758
  _context2.t0 = _context2["catch"](1);
72739
72759
  // Reject race if play fails
72740
72760
  reject('Play failed');
72741
- case 10:
72761
+ case 11:
72742
72762
  case "end":
72743
72763
  return _context2.stop();
72744
72764
  }
72745
- }, _callee2, null, [[1, 7]]);
72765
+ }, _callee2, null, [[1, 8]]);
72746
72766
  })), 100);
72747
72767
  }), new Promise(function (_, reject) {
72748
72768
  return setTimeout(function () {
72749
72769
  return reject('Timeout');
72750
72770
  }, 5000);
72751
72771
  })]).then(function () {
72752
- console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Autoplay started"));
72772
+ console.debug("VideoMedia: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Autoplay started"));
72753
72773
  })["catch"]( /*#__PURE__*/function () {
72754
72774
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(error) {
72755
72775
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
@@ -72759,12 +72779,12 @@ function VideoMedia(media, xlr) {
72759
72779
  _context3.next = 5;
72760
72780
  break;
72761
72781
  }
72762
- console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Promise not resolved within 5 seconds. Move to next media"));
72763
- videoMediaInstance.stop();
72782
+ console.debug("VideoMedia: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Promise not resolved within 5 seconds. Move to next media"));
72783
+ _this.stop();
72764
72784
  _context3.next = 9;
72765
72785
  break;
72766
72786
  case 5:
72767
- console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Autoplay error: ").concat(error));
72787
+ console.debug("VideoMedia: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " : Autoplay error: ").concat(error));
72768
72788
  if (!(xlr.config.platform === 'chromeOS')) {
72769
72789
  _context3.next = 9;
72770
72790
  break;
@@ -72782,16 +72802,12 @@ function VideoMedia(media, xlr) {
72782
72802
  };
72783
72803
  }());
72784
72804
  });
72785
- vjsPlayer.on('playing', function () {
72786
- console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " is now playing . . ."));
72787
- vjsPlayer.muted(media.muted);
72788
- });
72789
72805
  vjsPlayer.on('error', /*#__PURE__*/function () {
72790
72806
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(err) {
72791
72807
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
72792
72808
  while (1) switch (_context4.prev = _context4.next) {
72793
72809
  case 0:
72794
- console.debug("Media Error: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id));
72810
+ console.debug("VideoMedia: Media Error: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id));
72795
72811
  if (!(xlr.config.platform === 'chromeOS')) {
72796
72812
  _context4.next = 6;
72797
72813
  break;
@@ -72804,8 +72820,8 @@ function VideoMedia(media, xlr) {
72804
72820
  case 6:
72805
72821
  // End media after 5 seconds
72806
72822
  setTimeout(function () {
72807
- console.debug("".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has ended . . ."));
72808
- videoMediaInstance.stop();
72823
+ console.debug("VideoMedia: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has ended . . ."));
72824
+ _this.stop();
72809
72825
  }, 5000);
72810
72826
  case 7:
72811
72827
  case "end":
@@ -72820,10 +72836,7 @@ function VideoMedia(media, xlr) {
72820
72836
  if (media.duration === 0) {
72821
72837
  vjsPlayer.on('ended', function () {
72822
72838
  console.debug("VideoMedia: onended: ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has ended playing . . ."));
72823
- videoMediaInstance.stop();
72824
- });
72825
- vjsPlayer.on('durationchange', function () {
72826
- console.debug('VIDEOJS: ondurationchange: Showing Media ' + media.id + ' for ' + vjsPlayer.duration() + 's of Region ' + media.region.regionId);
72839
+ _this.stop();
72827
72840
  });
72828
72841
  }
72829
72842
  }
@@ -72837,10 +72850,11 @@ function VideoMedia(media, xlr) {
72837
72850
  media.emitter.emit('end', media);
72838
72851
  }
72839
72852
  vjsPlayer.dispose();
72853
+ // Clear up media player
72854
+ media.player = undefined;
72840
72855
  }
72841
72856
  }
72842
72857
  };
72843
- return videoMediaInstance;
72844
72858
  }
72845
72859
 
72846
72860
  function AudioMedia(media) {
@@ -72922,7 +72936,7 @@ function Media(region, mediaId, xml, options, xlr) {
72922
72936
  media.emitter.emit('end', media);
72923
72937
  if (media.mediaType === 'video') {
72924
72938
  // Dispose the video media
72925
- console.debug("VideoMedia::stop - ".concat(capitalizeStr(media.mediaType), " for media ").concat(media.id, " has been stopped."));
72939
+ console.debug("VideoMedia::stop - ".concat(capitalizeStr(media.mediaType), " for media > ").concat(media.id, " has ended playing . . ."));
72926
72940
  VideoMedia(media, xlr).stop(true);
72927
72941
  }
72928
72942
  }
@@ -72931,7 +72945,8 @@ function Media(region, mediaId, xml, options, xlr) {
72931
72945
  };
72932
72946
  emitter.on('start', function (media) {
72933
72947
  if (media.mediaType === 'video') {
72934
- VideoMedia(media, xlr).init();
72948
+ var videoMedia = VideoMedia(media, xlr);
72949
+ videoMedia.init();
72935
72950
  if (media.duration > 0) {
72936
72951
  startMediaTimer(media);
72937
72952
  }
@@ -73252,7 +73267,7 @@ function Media(region, mediaId, xml, options, xlr) {
73252
73267
  controls: false,
73253
73268
  preload: 'auto',
73254
73269
  autoplay: false,
73255
- muted: self.muted,
73270
+ muted: true,
73256
73271
  errorDisplay: xlr.config.platform !== 'chromeOS',
73257
73272
  loop: self.loop
73258
73273
  });