shaka-player 4.6.4 → 4.6.5

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.
@@ -864,7 +864,7 @@ shaka.media.MediaSourceEngine = class {
864
864
  const calculatedTimestampOffset = reference.startTime - timestamp;
865
865
  const timestampOffsetDifference =
866
866
  Math.abs(timestampOffset - calculatedTimestampOffset);
867
- if ((timestampOffsetDifference >= 0.1 || seeked || adaptation) &&
867
+ if ((timestampOffsetDifference >= 0.001 || seeked || adaptation) &&
868
868
  (!isChunkedData || calculatedTimestampOffset > 0 ||
869
869
  !timestampOffset)) {
870
870
  timestampOffset = calculatedTimestampOffset;
@@ -8,6 +8,7 @@ goog.provide('shaka.net.NetworkingUtils');
8
8
 
9
9
  goog.require('goog.Uri');
10
10
  goog.require('shaka.net.NetworkingEngine');
11
+ goog.require('shaka.util.Error');
11
12
 
12
13
 
13
14
  /**
@@ -30,13 +31,21 @@ shaka.net.NetworkingUtils = class {
30
31
  const type = shaka.net.NetworkingEngine.RequestType.MANIFEST;
31
32
 
32
33
  const request = shaka.net.NetworkingEngine.makeRequest([uri], retryParams);
33
- request.method = 'HEAD';
34
34
 
35
- const response = await netEngine.request(type, request).promise;
35
+ try {
36
+ request.method = 'HEAD';
37
+ const response = await netEngine.request(type, request).promise;
38
+ mimeType = response.headers['content-type'];
39
+ } catch (error) {
40
+ if (error && error.code == shaka.util.Error.Code.HTTP_ERROR) {
41
+ request.method = 'GET';
42
+ const response = await netEngine.request(type, request).promise;
43
+ mimeType = response.headers['content-type'];
44
+ }
45
+ }
36
46
 
37
47
  // https://bit.ly/2K9s9kf says this header should always be available,
38
48
  // but just to be safe:
39
- mimeType = response.headers['content-type'];
40
49
  return mimeType ? mimeType.toLowerCase().split(';').shift() : '';
41
50
  }
42
51
 
package/lib/player.js CHANGED
@@ -4525,7 +4525,7 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
4525
4525
 
4526
4526
  if (this.isLive()) {
4527
4527
  const now = this.getPresentationStartTimeAsDate().valueOf() +
4528
- this.seekRange().end * 1000;
4528
+ element.currentTime * 1000;
4529
4529
  const latency = (Date.now() - now) / 1000;
4530
4530
  this.stats_.setLiveLatency(latency);
4531
4531
  }
@@ -6779,7 +6779,7 @@ shaka.Player.TYPICAL_BUFFERING_THRESHOLD_ = 0.5;
6779
6779
  * @export
6780
6780
  */
6781
6781
  // eslint-disable-next-line no-useless-concat
6782
- shaka.Player.version = 'v4.6.4' + '-uncompiled'; // x-release-please-version
6782
+ shaka.Player.version = 'v4.6.5' + '-uncompiled'; // x-release-please-version
6783
6783
 
6784
6784
  // Initialize the deprecation system using the version string we just set
6785
6785
  // on the player.
@@ -614,9 +614,11 @@ shaka.util.TsParser = class {
614
614
  let sort = false;
615
615
  for (const audioData of this.audioData_) {
616
616
  const pes = this.parsePES_(audioData);
617
- if (pes && pes.pts != null && pes.dts != null) {
618
- if (this.audioPes_.length &&
619
- pes.dts < (this.audioPes_[this.audioPes_.length - 1].dts || 0)) {
617
+ let previousPes = this.audioPes_.length ?
618
+ this.audioPes_[this.audioPes_.length - 1] : null;
619
+ if (pes && pes.pts != null && pes.dts != null && (!previousPes ||
620
+ (previousPes.pts != pes.pts && previousPes.dts != pes.dts))) {
621
+ if (this.audioPes_.length && pes.dts < (previousPes.dts || 0)) {
620
622
  sort = true;
621
623
  }
622
624
  this.audioPes_.push(pes);
@@ -625,7 +627,7 @@ shaka.util.TsParser = class {
625
627
  if (!data) {
626
628
  continue;
627
629
  }
628
- const previousPes = this.audioPes_.pop();
630
+ previousPes = this.audioPes_.pop();
629
631
  previousPes.data =
630
632
  shaka.util.Uint8ArrayUtils.concat(previousPes.data, data);
631
633
  this.audioPes_.push(previousPes);
@@ -654,9 +656,11 @@ shaka.util.TsParser = class {
654
656
  let sort = false;
655
657
  for (const videoData of this.videoData_) {
656
658
  const pes = this.parsePES_(videoData);
657
- if (pes && pes.pts != null && pes.dts != null) {
658
- if (this.videoPes_.length &&
659
- pes.dts < (this.videoPes_[this.videoPes_.length - 1].dts || 0)) {
659
+ let previousPes = this.videoPes_.length ?
660
+ this.videoPes_[this.videoPes_.length - 1] : null;
661
+ if (pes && pes.pts != null && pes.dts != null && (!previousPes ||
662
+ (previousPes.pts != pes.pts && previousPes.dts != pes.dts))) {
663
+ if (this.videoPes_.length && pes.dts < (previousPes.dts || 0)) {
660
664
  sort = true;
661
665
  }
662
666
  this.videoPes_.push(pes);
@@ -665,7 +669,7 @@ shaka.util.TsParser = class {
665
669
  if (!data) {
666
670
  continue;
667
671
  }
668
- const previousPes = this.videoPes_.pop();
672
+ previousPes = this.videoPes_.pop();
669
673
  previousPes.data =
670
674
  shaka.util.Uint8ArrayUtils.concat(previousPes.data, data);
671
675
  this.videoPes_.push(previousPes);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "shaka-player",
3
3
  "description": "DASH/EME video player library",
4
- "version": "4.6.4",
4
+ "version": "4.6.5",
5
5
  "homepage": "https://github.com/shaka-project/shaka-player",
6
6
  "author": "Google",
7
7
  "maintainers": [
@@ -3484,6 +3484,37 @@ describe('Player', () => {
3484
3484
  expect(tracks[0].id).toBe(2);
3485
3485
  });
3486
3486
 
3487
+ it('removes based on frameRate', async () => {
3488
+ manifest = shaka.test.ManifestGenerator.generate((manifest) => {
3489
+ manifest.addVariant(0, (variant) => {
3490
+ variant.addVideo(1, (stream) => {
3491
+ stream.frameRate = 15;
3492
+ });
3493
+ });
3494
+
3495
+ manifest.addVariant(1, (variant) => {
3496
+ variant.addVideo(2, (stream) => {
3497
+ stream.frameRate = 30;
3498
+ });
3499
+ });
3500
+
3501
+ manifest.addVariant(2, (variant) => {
3502
+ variant.addVideo(3, (stream) => {
3503
+ stream.frameRate = 60;
3504
+ });
3505
+ });
3506
+ });
3507
+
3508
+ await player.load(fakeManifestUri, 0, fakeMimeType);
3509
+ expect(player.getVariantTracks().length).toBe(3);
3510
+
3511
+ player.configure({restrictions: {minFrameRate: 20, maxFrameRate: 40}});
3512
+
3513
+ const tracks = player.getVariantTracks();
3514
+ expect(tracks.length).toBe(1);
3515
+ expect(tracks[0].id).toBe(1);
3516
+ });
3517
+
3487
3518
  it('removes the whole variant if one stream is restricted', async () => {
3488
3519
  manifest = shaka.test.ManifestGenerator.generate((manifest) => {
3489
3520
  manifest.addVariant(0, (variant) => {
package/ui/volume_bar.js CHANGED
@@ -32,6 +32,10 @@ shaka.ui.VolumeBar = class extends shaka.ui.RangeElement {
32
32
  /** @private {!shaka.extern.UIConfiguration} */
33
33
  this.config_ = this.controls.getConfig();
34
34
 
35
+ // We use a range of 100 to avoid problems with Firefox.
36
+ // See https://github.com/shaka-project/shaka-player/issues/3987
37
+ this.setRange(0, 100);
38
+
35
39
  this.eventManager.listen(this.video,
36
40
  'volumechange',
37
41
  () => this.onPresentationVolumeChange_());
@@ -74,9 +78,9 @@ shaka.ui.VolumeBar = class extends shaka.ui.RangeElement {
74
78
  */
75
79
  onChange() {
76
80
  if (this.ad && this.ad.isLinear()) {
77
- this.ad.setVolume(this.getValue());
81
+ this.ad.setVolume(this.getValue() / 100);
78
82
  } else {
79
- this.video.volume = this.getValue();
83
+ this.video.volume = this.getValue() / 100;
80
84
  if (this.video.volume == 0) {
81
85
  this.video.muted = true;
82
86
  } else {
@@ -90,7 +94,7 @@ shaka.ui.VolumeBar = class extends shaka.ui.RangeElement {
90
94
  if (this.video.muted) {
91
95
  this.setValue(0);
92
96
  } else {
93
- this.setValue(this.video.volume);
97
+ this.setValue(this.video.volume * 100);
94
98
  }
95
99
 
96
100
  this.updateColors_();
@@ -102,7 +106,7 @@ shaka.ui.VolumeBar = class extends shaka.ui.RangeElement {
102
106
  'This.ad should exist at this point!');
103
107
 
104
108
  const volume = this.ad.getVolume();
105
- this.setValue(volume);
109
+ this.setValue(volume * 100);
106
110
  this.updateColors_();
107
111
  }
108
112
 
@@ -110,8 +114,8 @@ shaka.ui.VolumeBar = class extends shaka.ui.RangeElement {
110
114
  updateColors_() {
111
115
  const colors = this.config_.volumeBarColors;
112
116
  const gradient = ['to right'];
113
- gradient.push(colors.level + (this.getValue() * 100) + '%');
114
- gradient.push(colors.base + (this.getValue() * 100) + '%');
117
+ gradient.push(colors.level + this.getValue() + '%');
118
+ gradient.push(colors.base + this.getValue() + '%');
115
119
  gradient.push(colors.base + '100%');
116
120
 
117
121
  this.container.style.background =