lbry-desktop/ui/component/viewers
infinite-persistence 2dac41e5e5
Mute video when autoplay is blocked by browser policy (#6087)
## 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.
2021-05-19 11:56:54 -04:00
..
appViewer semi-broken 2020-04-29 11:00:42 -04:00
threeViewer Fix and enable 3D viewer: #4035 2020-04-27 14:27:04 -04:00
videoViewer Mute video when autoplay is blocked by browser policy (#6087) 2021-05-19 11:56:54 -04:00
codeViewer.jsx Remove alert 2020-02-07 09:21:28 -05:00
comicBookViewer.jsx fix comic-book content-type detection 2020-05-13 10:18:36 -04:00
documentViewer.jsx Only apply Staked Levels to Comments (allow it in Posts) 2021-04-09 11:27:07 -04:00
docxViewer.jsx semi-broken 2020-04-29 11:00:42 -04:00
htmlViewer.jsx semi-broken 2020-04-29 11:00:42 -04:00
imageViewer.jsx Open ZoomableImage viewer when clicking on the image 2021-02-19 14:05:51 -05:00
pdfViewer.jsx semi-broken 2020-04-29 11:00:42 -04:00