Mute video when autoplay is blocked by browser policy #6087

Merged
infinite-persistence merged 1 commit from ip/mute.video.for.autoplay.policy into master 2021-05-19 17:56:54 +02:00
infinite-persistence commented 2021-05-19 08:03:09 +02:00 (Migrated from github.com)

Issue

When opening a video directly in Chrome Incognito, the video should autoplay (since that's the default Lbry setting), but it doesn't due to browser policy
https://developers.google.com/web/updates/2017/09/autoplay-policy-changes

Changes

  • We don't want to forcefully mute the video when autoplay=true; we just want to do it when the browser policy is applied.
  • Fortunately, there is already an existing code-block for us to check that.

Test cases

  • "Autoplay=Off" should not be affected.
  • After manually unmuting, the next autoplayed video should not be muted (this is "user interacted" opening, so the policy allows autoplay)
  • If manually muting, the next autoplayed video should retain user's last setting.

Known issues

  • I've seen error occasionally being undefined in the catch block. In those cases, the solution doesn't work. We could remove if (player.autoplay() && !player.muted()) and simply just try muting it, but for now it's better to ensure NotAllowedError is due to unmuted first before applying the fix.
  • This doesn't work for Firefox as there is an explicit "Allow Autoplay" button in the address bar that user needs to click themselves. Applies to all sites.
## Issue When opening a video directly in Chrome Incognito, the video should autoplay (since that's the default Lbry setting), but it doesn't due to browser policy https://developers.google.com/web/updates/2017/09/autoplay-policy-changes ## Changes - We don't want to forcefully mute the video when `autoplay=true`; we just want to do it when the browser policy is applied. - Fortunately, there is already an existing code-block for us to check that. ## Test cases - [x] "Autoplay=Off" should not be affected. - [x] After manually unmuting, the next autoplayed video should not be muted (this is "user interacted" opening, so the policy allows autoplay) - [x] If manually muting, the next autoplayed video should retain user's last setting. ## Known issues - I've seen `error` occasionally being undefined in the `catch` block. In those cases, the solution doesn't work. We could remove `if (player.autoplay() && !player.muted())` and simply just try muting it, but for now it's better to ensure `NotAllowedError` is due to unmuted first before applying the fix. - This doesn't work for Firefox as there is an explicit "Allow Autoplay" button in the address bar that user needs to click themselves. Applies to all sites.
tzarebczan (Migrated from github.com) reviewed 2021-05-19 08:03:09 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: LBRYCommunity/lbry-desktop#6087
No description provided.