shaka-player 4.6.9 → 4.6.10
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/CHANGELOG.md +9 -0
- package/dist/locales.js +33 -33
- package/dist/shaka-player.compiled.debug.js +10 -10
- package/dist/shaka-player.compiled.debug.map +2 -2
- package/dist/shaka-player.compiled.js +380 -380
- package/dist/shaka-player.compiled.map +2 -2
- package/dist/shaka-player.ui.debug.js +17 -19
- package/dist/shaka-player.ui.debug.map +3 -3
- package/dist/shaka-player.ui.js +289 -289
- package/dist/shaka-player.ui.map +2 -2
- package/lib/player.js +6 -3
- package/lib/util/platform.js +18 -0
- package/lib/util/stream_utils.js +14 -0
- package/package.json +1 -1
- package/test/player_unit.js +19 -4
- package/ui/controls.js +3 -0
- package/ui/pip_button.js +5 -21
package/lib/player.js
CHANGED
|
@@ -4536,13 +4536,16 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
|
|
|
4536
4536
|
// variant yet because we set the load mode before we select the first
|
|
4537
4537
|
// variant to stream.
|
|
4538
4538
|
const variant = this.streamingEngine_.getCurrentVariant();
|
|
4539
|
+
const textStream = this.streamingEngine_.getCurrentTextStream();
|
|
4539
4540
|
|
|
4540
4541
|
if (variant) {
|
|
4541
4542
|
const rate = this.playRateController_ ?
|
|
4542
4543
|
this.playRateController_.getRealRate() : 1;
|
|
4543
4544
|
const variantBandwidth = rate * variant.bandwidth;
|
|
4544
|
-
|
|
4545
|
-
|
|
4545
|
+
let currentStreamBandwidth = variantBandwidth;
|
|
4546
|
+
if (textStream && textStream.bandwidth) {
|
|
4547
|
+
currentStreamBandwidth += (rate * textStream.bandwidth);
|
|
4548
|
+
}
|
|
4546
4549
|
this.stats_.setCurrentStreamBandwidth(currentStreamBandwidth);
|
|
4547
4550
|
}
|
|
4548
4551
|
|
|
@@ -6814,7 +6817,7 @@ shaka.Player.TYPICAL_BUFFERING_THRESHOLD_ = 0.5;
|
|
|
6814
6817
|
* @export
|
|
6815
6818
|
*/
|
|
6816
6819
|
// eslint-disable-next-line no-useless-concat
|
|
6817
|
-
shaka.Player.version = 'v4.6.
|
|
6820
|
+
shaka.Player.version = 'v4.6.10' + '-uncompiled'; // x-release-please-version
|
|
6818
6821
|
|
|
6819
6822
|
// Initialize the deprecation system using the version string we just set
|
|
6820
6823
|
// on the player.
|
package/lib/util/platform.js
CHANGED
|
@@ -220,6 +220,15 @@ shaka.util.Platform = class {
|
|
|
220
220
|
!shaka.util.Platform.isLegacyEdge();
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
+
/**
|
|
224
|
+
* Check if the current platform is Firefox.
|
|
225
|
+
*
|
|
226
|
+
* @return {boolean}
|
|
227
|
+
*/
|
|
228
|
+
static isFirefox() {
|
|
229
|
+
return shaka.util.Platform.userAgentContains_('Firefox');
|
|
230
|
+
}
|
|
231
|
+
|
|
223
232
|
/**
|
|
224
233
|
* Check if the current platform is from Apple.
|
|
225
234
|
*
|
|
@@ -422,6 +431,15 @@ shaka.util.Platform = class {
|
|
|
422
431
|
return navigator.platform.toLowerCase().includes('windows');
|
|
423
432
|
}
|
|
424
433
|
|
|
434
|
+
/**
|
|
435
|
+
* Return true if the platform is a Android, regardless of the browser.
|
|
436
|
+
*
|
|
437
|
+
* @return {boolean}
|
|
438
|
+
*/
|
|
439
|
+
static isAndroid() {
|
|
440
|
+
return shaka.util.Platform.userAgentContains_('Android');
|
|
441
|
+
}
|
|
442
|
+
|
|
425
443
|
/**
|
|
426
444
|
* Check if the user agent contains a key. This is the best way we know of
|
|
427
445
|
* right now to detect platforms. If there is a better way, please send a
|
package/lib/util/stream_utils.js
CHANGED
|
@@ -370,6 +370,9 @@ shaka.util.StreamUtils = class {
|
|
|
370
370
|
const StreamUtils = shaka.util.StreamUtils;
|
|
371
371
|
const isXboxOne = shaka.util.Platform.isXboxOne();
|
|
372
372
|
|
|
373
|
+
const isFirefoxAndroid = shaka.util.Platform.isFirefox() &&
|
|
374
|
+
shaka.util.Platform.isAndroid();
|
|
375
|
+
|
|
373
376
|
manifest.variants = manifest.variants.filter((variant) => {
|
|
374
377
|
// See: https://github.com/shaka-project/shaka-player/issues/3860
|
|
375
378
|
const video = variant.video;
|
|
@@ -425,6 +428,17 @@ shaka.util.StreamUtils = class {
|
|
|
425
428
|
|
|
426
429
|
const audio = variant.audio;
|
|
427
430
|
|
|
431
|
+
// See: https://github.com/shaka-project/shaka-player/issues/6111
|
|
432
|
+
// It seems that Firefox Android reports that it supports
|
|
433
|
+
// Opus + Widevine, but it is not actually supported.
|
|
434
|
+
// It makes sense to drop early.
|
|
435
|
+
if (isFirefoxAndroid && audio && audio.encrypted &&
|
|
436
|
+
audio.codecs.toLowerCase().includes('opus')) {
|
|
437
|
+
shaka.log.debug('Dropping variant - not compatible with platform',
|
|
438
|
+
StreamUtils.getVariantSummaryString_(variant));
|
|
439
|
+
return false;
|
|
440
|
+
}
|
|
441
|
+
|
|
428
442
|
if (audio) {
|
|
429
443
|
const codecs = StreamUtils.getCorrectAudioCodecs_(audio.codecs);
|
|
430
444
|
const fullType = MimeUtils.getFullOrConvertedType(
|
package/package.json
CHANGED
package/test/player_unit.js
CHANGED
|
@@ -2633,6 +2633,9 @@ describe('Player', () => {
|
|
|
2633
2633
|
variant.addExistingStream(1); // audio
|
|
2634
2634
|
variant.addExistingStream(2); // video
|
|
2635
2635
|
});
|
|
2636
|
+
manifest.addTextStream(4, (stream) => {
|
|
2637
|
+
stream.bandwidth = 10;
|
|
2638
|
+
});
|
|
2636
2639
|
});
|
|
2637
2640
|
|
|
2638
2641
|
await player.load(fakeManifestUri, 0, fakeMimeType);
|
|
@@ -2649,11 +2652,15 @@ describe('Player', () => {
|
|
|
2649
2652
|
});
|
|
2650
2653
|
|
|
2651
2654
|
it('tracks info about current stream', () => {
|
|
2652
|
-
|
|
2655
|
+
let stats = player.getStats();
|
|
2653
2656
|
// Should have chosen the first of each type of stream.
|
|
2654
2657
|
expect(stats.width).toBe(100);
|
|
2655
2658
|
expect(stats.height).toBe(200);
|
|
2656
2659
|
expect(stats.streamBandwidth).toBe(200);
|
|
2660
|
+
const textTracks = player.getTextTracks();
|
|
2661
|
+
player.selectTextTrack(textTracks[0]);
|
|
2662
|
+
stats = player.getStats();
|
|
2663
|
+
expect(stats.streamBandwidth).toBe(210);
|
|
2657
2664
|
});
|
|
2658
2665
|
|
|
2659
2666
|
it('tracks frame info', () => {
|
|
@@ -2768,7 +2775,7 @@ describe('Player', () => {
|
|
|
2768
2775
|
* @param {!Array.<shaka.extern.TrackChoice>} additional
|
|
2769
2776
|
*/
|
|
2770
2777
|
function checkHistory(additional) {
|
|
2771
|
-
const
|
|
2778
|
+
const variantPrefix = {
|
|
2772
2779
|
timestamp: jasmine.any(Number),
|
|
2773
2780
|
id: 0,
|
|
2774
2781
|
type: 'variant',
|
|
@@ -2776,10 +2783,18 @@ describe('Player', () => {
|
|
|
2776
2783
|
bandwidth: 200,
|
|
2777
2784
|
};
|
|
2778
2785
|
|
|
2786
|
+
const textPrefix = {
|
|
2787
|
+
timestamp: jasmine.any(Number),
|
|
2788
|
+
id: 4,
|
|
2789
|
+
type: 'text',
|
|
2790
|
+
fromAdaptation: true,
|
|
2791
|
+
bandwidth: null,
|
|
2792
|
+
};
|
|
2779
2793
|
const switchHistory = player.getStats().switchHistory;
|
|
2780
2794
|
|
|
2781
|
-
expect(switchHistory[0]).toEqual(
|
|
2782
|
-
expect(switchHistory
|
|
2795
|
+
expect(switchHistory[0]).toEqual(variantPrefix);
|
|
2796
|
+
expect(switchHistory[1]).toEqual(textPrefix);
|
|
2797
|
+
expect(switchHistory.slice(2)).toEqual(additional);
|
|
2783
2798
|
}
|
|
2784
2799
|
|
|
2785
2800
|
/**
|
package/ui/controls.js
CHANGED
|
@@ -648,6 +648,9 @@ shaka.ui.Controls = class extends shaka.util.FakeEventTarget {
|
|
|
648
648
|
* @export
|
|
649
649
|
*/
|
|
650
650
|
isPiPAllowed() {
|
|
651
|
+
if (this.castProxy_.isCasting()) {
|
|
652
|
+
return false;
|
|
653
|
+
}
|
|
651
654
|
if ('documentPictureInPicture' in window &&
|
|
652
655
|
this.config_.preferDocumentPictureInPicture) {
|
|
653
656
|
const video = /** @type {HTMLVideoElement} */(this.localVideo_);
|
package/ui/pip_button.js
CHANGED
|
@@ -98,8 +98,8 @@ shaka.ui.PipButton = class extends shaka.ui.Element {
|
|
|
98
98
|
this.onLeavePictureInPicture_();
|
|
99
99
|
});
|
|
100
100
|
|
|
101
|
-
this.eventManager.listen(this.controls, 'caststatuschanged', (
|
|
102
|
-
this.
|
|
101
|
+
this.eventManager.listen(this.controls, 'caststatuschanged', () => {
|
|
102
|
+
this.onTracksChanged_();
|
|
103
103
|
});
|
|
104
104
|
|
|
105
105
|
this.eventManager.listen(this.player, 'trackschanged', () => {
|
|
@@ -164,25 +164,6 @@ shaka.ui.PipButton = class extends shaka.ui.Element {
|
|
|
164
164
|
this.localization.resolve(currentPipState);
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
/**
|
|
168
|
-
* @param {Event} e
|
|
169
|
-
* @private
|
|
170
|
-
*/
|
|
171
|
-
onCastStatusChange_(e) {
|
|
172
|
-
const isCasting = e['newStatus'];
|
|
173
|
-
|
|
174
|
-
if (isCasting) {
|
|
175
|
-
// Picture-in-picture is not applicable if we're casting
|
|
176
|
-
if (this.controls.isPiPAllowed()) {
|
|
177
|
-
shaka.ui.Utils.setDisplay(this.pipButton_, false);
|
|
178
|
-
}
|
|
179
|
-
} else {
|
|
180
|
-
if (this.controls.isPiPAllowed()) {
|
|
181
|
-
shaka.ui.Utils.setDisplay(this.pipButton_, true);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
167
|
|
|
187
168
|
/**
|
|
188
169
|
* Display the picture-in-picture button only when the content contains video.
|
|
@@ -194,6 +175,9 @@ shaka.ui.PipButton = class extends shaka.ui.Element {
|
|
|
194
175
|
async onTracksChanged_() {
|
|
195
176
|
if (!this.controls.isPiPAllowed()) {
|
|
196
177
|
shaka.ui.Utils.setDisplay(this.pipButton_, false);
|
|
178
|
+
if (this.controls.isPiPEnabled()) {
|
|
179
|
+
await this.controls.togglePiP();
|
|
180
|
+
}
|
|
197
181
|
} else if (this.player && this.player.isAudioOnly()) {
|
|
198
182
|
shaka.ui.Utils.setDisplay(this.pipButton_, false);
|
|
199
183
|
if (this.controls.isPiPEnabled()) {
|