Skip to content

Commit

Permalink
fix: try again on volume feature detection on iOS (#7514)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gkatsev authored Nov 17, 2021
1 parent 8f580cc commit 1d96d1c
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/js/tech/html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 1d96d1c

Please sign in to comment.