@clappr/player 0.8.0 → 0.10.0

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.
package/dist/clappr.js CHANGED
@@ -3826,6 +3826,13 @@
3826
3826
  */
3827
3827
  Events$1.PLAYBACK_AUDIO_CHANGED = 'playback:audio:changed';
3828
3828
 
3829
+ /**
3830
+ * Fired when the playback was resized.
3831
+ *
3832
+ * @event PLAYBACK_RESIZE
3833
+ */
3834
+ Events$1.PLAYBACK_RESIZE = 'playback:resize';
3835
+
3829
3836
  // Core Events
3830
3837
  /**
3831
3838
  * Fired when the containers are created
@@ -4530,6 +4537,34 @@
4530
4537
  this.setElement(this.el, false);
4531
4538
  }
4532
4539
  }
4540
+
4541
+ /**
4542
+ * method called before resize the element
4543
+ * @method onResize
4544
+ * @return {UIObject} itself
4545
+ */
4546
+ }, {
4547
+ key: "onResize",
4548
+ value: function onResize() {
4549
+ return this;
4550
+ }
4551
+
4552
+ /**
4553
+ * resize current element
4554
+ * @method resize
4555
+ * @param {Object} options the options object
4556
+ * @return {UIObject} itself
4557
+ */
4558
+ }, {
4559
+ key: "resize",
4560
+ value: function resize(options) {
4561
+ var newWidth = isNumber(options.width) ? "".concat(options.width, "px") : "".concat(options.width);
4562
+ var newHeight = isNumber(options.height) ? "".concat(options.height, "px") : "".concat(options.height);
4563
+ this.el.style.width = newWidth;
4564
+ this.el.style.height = newHeight;
4565
+ this.onResize(options);
4566
+ return this;
4567
+ }
4533
4568
  }]);
4534
4569
  }(BaseObject);
4535
4570
 
@@ -5007,11 +5042,6 @@
5007
5042
  value: function setStyle(style) {
5008
5043
  this.$el.css(style);
5009
5044
  }
5010
- }, {
5011
- key: "animate",
5012
- value: function animate(style, duration) {
5013
- return this.$el.animate(style, duration).promise();
5014
- }
5015
5045
  }, {
5016
5046
  key: "ready",
5017
5047
  value: function ready() {
@@ -5358,10 +5388,22 @@
5358
5388
  width = _ref.width,
5359
5389
  height = _ref.height;
5360
5390
  var isResize = height !== newSize.height || width !== newSize.width;
5361
- if (isResize) {
5362
- this.currentSize = newSize;
5363
- this.trigger(Events$1.CONTAINER_RESIZE, newSize);
5364
- }
5391
+ if (!isResize) return;
5392
+ this.currentSize = newSize;
5393
+ this.trigger(Events$1.CONTAINER_RESIZE, newSize);
5394
+ }
5395
+
5396
+ /**
5397
+ * method called before resize the element
5398
+ * @method onResize
5399
+ * @param {Object} options the options object
5400
+ * @return {UIObject} itself
5401
+ */
5402
+ }, {
5403
+ key: "onResize",
5404
+ value: function onResize(options) {
5405
+ this.playback.resize(options);
5406
+ return this;
5365
5407
  }
5366
5408
 
5367
5409
  /**
@@ -5787,6 +5829,19 @@
5787
5829
  value: function canAutoPlay(cb) {
5788
5830
  cb(true, null); // Assume playback can autoplay by default
5789
5831
  }
5832
+
5833
+ /**
5834
+ * method called before resize the element
5835
+ * @method onResize
5836
+ * @param {Object} options the options object
5837
+ * @return {UIObject} itself
5838
+ */
5839
+ }, {
5840
+ key: "onResize",
5841
+ value: function onResize(options) {
5842
+ this.trigger(Events$1.PLAYBACK_RESIZE, options);
5843
+ return this;
5844
+ }
5790
5845
  }]);
5791
5846
  }(UIObject);
5792
5847
  Object.assign(Playback.prototype, ErrorMixin);
@@ -6125,16 +6180,16 @@
6125
6180
  };
6126
6181
  this.resize(this.currentSize);
6127
6182
  }
6183
+
6184
+ /**
6185
+ * method called before resize the element
6186
+ * @method onResize
6187
+ * @param {Object} options the options object
6188
+ * @return {UIObject} itself
6189
+ */
6128
6190
  }, {
6129
- key: "resize",
6130
- value: function resize(options) {
6131
- if (!isNumber(options.height) && !isNumber(options.width)) {
6132
- this.el.style.height = "".concat(options.height);
6133
- this.el.style.width = "".concat(options.width);
6134
- } else {
6135
- this.el.style.height = "".concat(options.height, "px");
6136
- this.el.style.width = "".concat(options.width, "px");
6137
- }
6191
+ key: "onResize",
6192
+ value: function onResize(options) {
6138
6193
  this.previousSize = {
6139
6194
  width: this.options.width,
6140
6195
  height: this.options.height
@@ -6143,6 +6198,7 @@
6143
6198
  this.options.height = options.height;
6144
6199
  this.currentSize = options;
6145
6200
  this.triggerResize(this.currentSize);
6201
+ return this;
6146
6202
  }
6147
6203
  }, {
6148
6204
  key: "enableResizeObserver",
@@ -6161,13 +6217,12 @@
6161
6217
  key: "triggerResize",
6162
6218
  value: function triggerResize(newSize) {
6163
6219
  var thereWasChange = this.firstResize || this.oldHeight !== newSize.height || this.oldWidth !== newSize.width;
6164
- if (thereWasChange) {
6165
- this.oldHeight = newSize.height;
6166
- this.oldWidth = newSize.width;
6167
- this.computedSize = newSize;
6168
- this.firstResize = false;
6169
- this.trigger(Events$1.CORE_RESIZE, newSize);
6170
- }
6220
+ if (!thereWasChange) return;
6221
+ this.oldHeight = newSize.height;
6222
+ this.oldWidth = newSize.width;
6223
+ this.computedSize = newSize;
6224
+ this.firstResize = false;
6225
+ this.trigger(Events$1.CORE_RESIZE, newSize);
6171
6226
  }
6172
6227
  }, {
6173
6228
  key: "disableResizeObserver",
@@ -6562,7 +6617,7 @@
6562
6617
  plugins: {},
6563
6618
  playbacks: []
6564
6619
  };
6565
- var currentVersion = "0.9.0";
6620
+ var currentVersion = "0.10.0";
6566
6621
  return /*#__PURE__*/function () {
6567
6622
  /**
6568
6623
  * builds the loader
@@ -7697,7 +7752,7 @@
7697
7752
  key: "supportedVersion",
7698
7753
  get: function get() {
7699
7754
  return {
7700
- min: "0.9.0"
7755
+ min: "0.10.0"
7701
7756
  };
7702
7757
  }
7703
7758
  }, {
@@ -8459,7 +8514,7 @@
8459
8514
  key: "supportedVersion",
8460
8515
  get: function get() {
8461
8516
  return {
8462
- min: "0.9.0"
8517
+ min: "0.10.0"
8463
8518
  };
8464
8519
  }
8465
8520
  }, {
@@ -8514,7 +8569,7 @@
8514
8569
  key: "supportedVersion",
8515
8570
  get: function get() {
8516
8571
  return {
8517
- min: "0.9.0"
8572
+ min: "0.10.0"
8518
8573
  };
8519
8574
  }
8520
8575
  }, {
@@ -8594,7 +8649,7 @@
8594
8649
  key: "supportedVersion",
8595
8650
  get: function get() {
8596
8651
  return {
8597
- min: "0.9.0"
8652
+ min: "0.10.0"
8598
8653
  };
8599
8654
  }
8600
8655
  }, {
@@ -8720,7 +8775,7 @@
8720
8775
  key: "supportedVersion",
8721
8776
  get: function get() {
8722
8777
  return {
8723
- min: "0.9.0"
8778
+ min: "0.10.0"
8724
8779
  };
8725
8780
  }
8726
8781
  }, {
@@ -8861,7 +8916,7 @@
8861
8916
  key: "supportedVersion",
8862
8917
  get: function get() {
8863
8918
  return {
8864
- min: "0.9.0"
8919
+ min: "0.10.0"
8865
8920
  };
8866
8921
  }
8867
8922
  }, {
@@ -8890,7 +8945,7 @@
8890
8945
  @type {string}
8891
8946
  @default
8892
8947
  */
8893
- var version$1 = "0.9.0";
8948
+ var version$1 = "0.10.0";
8894
8949
 
8895
8950
  // Built-in Plugins/Playbacks
8896
8951
 
@@ -9054,7 +9109,7 @@
9054
9109
  key: "supportedVersion",
9055
9110
  get: function get() {
9056
9111
  return {
9057
- min: "0.9.0"
9112
+ min: "0.10.0"
9058
9113
  };
9059
9114
  }
9060
9115
  }, {
@@ -9113,7 +9168,7 @@
9113
9168
  key: "supportedVersion",
9114
9169
  get: function get() {
9115
9170
  return {
9116
- min: "0.9.0"
9171
+ min: "0.10.0"
9117
9172
  };
9118
9173
  }
9119
9174
  }, {
@@ -9272,7 +9327,7 @@
9272
9327
  key: "supportedVersion",
9273
9328
  get: function get() {
9274
9329
  return {
9275
- min: "0.9.0"
9330
+ min: "0.10.0"
9276
9331
  };
9277
9332
  }
9278
9333
  }, {
@@ -9399,7 +9454,7 @@
9399
9454
  key: "supportedVersion",
9400
9455
  get: function get() {
9401
9456
  return {
9402
- min: "0.9.0"
9457
+ min: "0.10.0"
9403
9458
  };
9404
9459
  }
9405
9460
  }, {
@@ -9447,7 +9502,7 @@
9447
9502
  key: "supportedVersion",
9448
9503
  get: function get() {
9449
9504
  return {
9450
- min: "0.9.0"
9505
+ min: "0.10.0"
9451
9506
  };
9452
9507
  }
9453
9508
  }, {
@@ -9567,7 +9622,7 @@
9567
9622
  key: "supportedVersion",
9568
9623
  get: function get() {
9569
9624
  return {
9570
- min: "0.9.0"
9625
+ min: "0.10.0"
9571
9626
  };
9572
9627
  }
9573
9628
  }, {
@@ -9686,7 +9741,7 @@
9686
9741
  key: "supportedVersion",
9687
9742
  get: function get() {
9688
9743
  return {
9689
- min: "0.9.0"
9744
+ min: "0.10.0"
9690
9745
  };
9691
9746
  }
9692
9747
  }, {
@@ -10176,7 +10231,7 @@
10176
10231
  key: "supportedVersion",
10177
10232
  get: function get() {
10178
10233
  return {
10179
- min: "0.9.0"
10234
+ min: "0.10.0"
10180
10235
  };
10181
10236
  }
10182
10237
  }, {
@@ -10976,7 +11031,7 @@
10976
11031
  key: "supportedVersion",
10977
11032
  get: function get() {
10978
11033
  return {
10979
- min: "0.9.0"
11034
+ min: "0.10.0"
10980
11035
  };
10981
11036
  }
10982
11037
  }, {
@@ -11179,7 +11234,7 @@
11179
11234
  key: "supportedVersion",
11180
11235
  get: function get() {
11181
11236
  return {
11182
- min: "0.9.0"
11237
+ min: "0.10.0"
11183
11238
  };
11184
11239
  }
11185
11240
  }, {
@@ -11381,7 +11436,7 @@
11381
11436
  key: "supportedVersion",
11382
11437
  get: function get() {
11383
11438
  return {
11384
- min: "0.9.0"
11439
+ min: "0.10.0"
11385
11440
  };
11386
11441
  }
11387
11442
  }, {
@@ -11459,7 +11514,7 @@
11459
11514
  key: "supportedVersion",
11460
11515
  get: function get() {
11461
11516
  return {
11462
- min: "0.9.0"
11517
+ min: "0.10.0"
11463
11518
  };
11464
11519
  }
11465
11520
  }, {
@@ -11580,7 +11635,7 @@
11580
11635
  key: "supportedVersion",
11581
11636
  get: function get() {
11582
11637
  return {
11583
- min: "0.9.0"
11638
+ min: "0.10.0"
11584
11639
  };
11585
11640
  }
11586
11641
  }, {
@@ -11652,7 +11707,7 @@
11652
11707
  WaterMark: WaterMarkPlugin
11653
11708
  };
11654
11709
 
11655
- var version = "0.8.0";
11710
+ var version = "0.10.0";
11656
11711
  for (var _i = 0, _Object$values = Object.values(Plugins); _i < _Object$values.length; _i++) {
11657
11712
  var plugin = _Object$values[_i];
11658
11713
  Loader.registerPlugin(plugin);
@@ -40331,6 +40386,7 @@
40331
40386
  }
40332
40387
  _this = _super.call.apply(_super, [this].concat(args));
40333
40388
  _this.options.hlsPlayback = _objectSpread2$1(_objectSpread2$1({}, _this.defaultOptions), _this.options.hlsPlayback);
40389
+ _this._timeUpdateThrottleDelay = 200;
40334
40390
  _this._timeUpdateFiringRate = 0.2;
40335
40391
  _this._durationChangeMinOffset = 0.5;
40336
40392
  _this._setInitialState();
@@ -40345,7 +40401,7 @@
40345
40401
  key: "supportedVersion",
40346
40402
  get: function get() {
40347
40403
  return {
40348
- min: "0.9.0"
40404
+ min: "0.10.0"
40349
40405
  };
40350
40406
  }
40351
40407
  }, {
@@ -40492,6 +40548,7 @@
40492
40548
  total: 0,
40493
40549
  firstFragDateTime: 0
40494
40550
  };
40551
+ this._lastTimeUpdateFiredTime = 0;
40495
40552
  this._lastDuration = null;
40496
40553
  // for hls streams which have dvr with a sliding window,
40497
40554
  // the content at the start of the playlist is removed as new
@@ -40570,7 +40627,7 @@
40570
40627
  this._hls.on(Hls.Events.LEVEL_UPDATED, function (evt, data) {
40571
40628
  return _this2._onLevelUpdated(evt, data);
40572
40629
  });
40573
- this._hls.on(Hls.Events.LEVEL_SWITCHING, function (evt, data) {
40630
+ this._hls.on(Hls.Events.LEVEL_SWITCHED, function (evt, data) {
40574
40631
  return _this2._onLevelSwitch(evt, data);
40575
40632
  });
40576
40633
  this._hls.on(Hls.Events.FRAG_CHANGED, function (evt, data) {
@@ -40845,13 +40902,21 @@
40845
40902
  total: this.getDuration(),
40846
40903
  firstFragDateTime: this.getProgramDateTime()
40847
40904
  };
40905
+ var shouldThrottle = this._shouldThrottleTimeUpdate(update);
40906
+ if (shouldThrottle) return;
40907
+ this._lastTimeUpdate = update;
40908
+ this._lastTimeUpdateFiredTime = this._now;
40909
+ this.trigger(Events$1.PLAYBACK_TIMEUPDATE, update, this.name);
40910
+ }
40911
+ }, {
40912
+ key: "_shouldThrottleTimeUpdate",
40913
+ value: function _shouldThrottleTimeUpdate(update) {
40848
40914
  var isSameTime = Math.abs(update.current - this._lastTimeUpdate.current) < this._timeUpdateFiringRate;
40849
40915
  var isSameDuration = Math.abs(update.total - this._lastTimeUpdate.total) < this._durationChangeMinOffset;
40850
40916
  var isSameFirstFragDateTime = update.firstFragDateTime === this._lastTimeUpdate.firstFragDateTime;
40851
- var isSame = isSameTime && isSameDuration && isSameFirstFragDateTime;
40852
- if (isSame) return;
40853
- this._lastTimeUpdate = update;
40854
- this.trigger(Events$1.PLAYBACK_TIMEUPDATE, update, this.name);
40917
+ var isSameEventPayload = isSameTime && isSameDuration && isSameFirstFragDateTime;
40918
+ var isThrottled = this._now - this._lastTimeUpdateFiredTime < this._timeUpdateThrottleDelay;
40919
+ return isSameEventPayload && isThrottled;
40855
40920
  }
40856
40921
  }, {
40857
40922
  key: "_onDurationChange",