1
0
mirror of https://github.com/videojs/video.js.git synced 2024-12-04 10:34:51 +02:00

fix: try again on volume feature detection on iOS (#7514)

On latest iOS, we are seeing times when the volume feature detection is
showing that we are able to change the volume, though, that is not the
case. Instead, on iOS, when we detect that we can control the volume, we
set a short timer to retest and reset the featuresVolumeControl property.

Fixes #7040
This commit is contained in:
Gary Katsevman 2021-11-17 12:27:08 -05:00 committed by GitHub
parent 8f580ccc81
commit 1d96d1cf20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1032,7 +1032,21 @@ Html5.canControlVolume = function() {
const volume = Html5.TEST_VID.volume;
Html5.TEST_VID.volume = (volume / 2) + 0.1;
return volume !== Html5.TEST_VID.volume;
const canControl = volume !== Html5.TEST_VID.volume;
// With the introduction of iOS 15, there are cases where the volume is read as
// changed but reverts back to its original state at the start of the next tick.
// To determine whether volume can be controlled on iOS,
// a timeout is set and the volume is checked asynchronously.
// Since `features` doesn't currently work asynchronously, the value is manually set.
if (canControl && browser.IS_IOS) {
window.setTimeout(() => {
Html5.prototype.featuresVolumeControl = volume !== Html5.TEST_VID.volume;
});
}
return canControl;
} catch (e) {
return false;
}