Skip to content

Commit 5413b5f

Browse files
authored
fix: Detect screen change to update ABR according HDR vs SDR (#8606)
1 parent 1d04801 commit 5413b5f

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

lib/media/adaptation_set_criteria.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ shaka.media.AdaptationSetCriteria = class {
3636
* @exportInterface
3737
*/
3838
configure(config) {}
39+
40+
/**
41+
* Gets the current AdaptationSetCriteria configuration.
42+
*
43+
* @return {?shaka.media.AdaptationSetCriteria.Configuration}
44+
* @exportInterface
45+
*/
46+
getConfiguration() {}
3947
};
4048

4149
/**

lib/media/preference_based_criteria.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ shaka.media.PreferenceBasedCriteria = class {
3333
this.config_ = config;
3434
}
3535

36+
/**
37+
* @override
38+
*/
39+
getConfiguration() {
40+
return this.config_;
41+
}
42+
3643
/**
3744
* @override
3845
*/

lib/player.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2742,6 +2742,24 @@ shaka.Player = class extends shaka.util.FakeEventTarget {
27422742
// Add all media element listeners.
27432743
this.addBasicMediaListeners_(mediaElement, startTimeOfLoad);
27442744

2745+
if ('onchange' in window.screen) {
2746+
this.loadEventManager_.listen(
2747+
/** @type {EventTarget} */(window.screen), 'change', () => {
2748+
if (this.currentAdaptationSetCriteria_.getConfiguration) {
2749+
const config =
2750+
this.currentAdaptationSetCriteria_.getConfiguration();
2751+
if (config.hdrLevel == 'AUTO') {
2752+
this.updateAbrManagerVariants_();
2753+
} else if (this.config_.preferredVideoHdrLevel == 'AUTO' &&
2754+
this.config_.abr.enabled) {
2755+
config.hdrLevel = 'AUTO';
2756+
this.currentAdaptationSetCriteria_.configure(config);
2757+
this.updateAbrManagerVariants_();
2758+
}
2759+
}
2760+
});
2761+
}
2762+
27452763
let isLcevcDualTrack = false;
27462764
for (const variant of this.manifest_.variants) {
27472765
const dependencyStream = variant.video && variant.video.dependencyStream;

0 commit comments

Comments
 (0)