Skip to content

Commit

Permalink
fix: try again on volume feature detection on iOS (videojs#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 videojs#7040
  • Loading branch information
gkatsev authored and edirub committed Jun 8, 2023
1 parent 2e365bf commit d9dc117
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 d9dc117

Please sign in to comment.