Cover Block: User can't play background video on devices in low power mode
Description
When using a background video in a cover block, devices that are in "low power mode" will not autoplay the video. The browser adds a play button over the video in this case, but the user is unable to click or tap that play button. Those events are impacted by the overlay functionality of the cover block -- they are caught by the .wp-block-cover__background span and not passed to the button added to the .wp-block-cover__video-background video element.
Step-by-step reproduction instructions
- On iPhone, go to settings / battery, and enable "low power mode".
- Open browser (Safari or Chrome)
- Visit site with background video in cover block
- The video will not be playing, but you should see a play button overlaid on the video. Clicking on that play button will not work.
Screenshots, screen recording, code snippet
Environment info
WordPress 6.6.1 iPhone 14 Pro (iOS 17.6)
Please confirm that you have searched existing issues in the repo.
- [X] Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
- [X] Yes
I'm interested to solve this issue, I was able to find couple of solutions to this problem as well But I'm not sure how can I actually replicate this 'Low power mode on iPhone' issue on Mac ( chrome or safari ), any suggestions ? Thanks in advance 🙇
@Rishit30G Try these:
- https://developer.apple.com/documentation/safari-developer-tools/inspecting-ios
- https://developer.chrome.com/blog/debugging-chrome-on-ios
If i remember well you can install XCode on Mac and then launch a sub tool called Simulator, which allows you to launch a iOS device emulation. With that you will have an iPhone and also ability to trigger "Low power mode". Not tested.
Thanks @tresorama and @bhdd 🙇
I was able to see where the exact issue is, there is a Shadow Content (User Agent) that gets embedded to <video/> tag as soon as the Low Power Mode is triggered, this brings the play button over the video:
To avoid this we can maybe try using this:
video::-webkit-media-controls {
display: none !important;
}
@Rishit30G I would hope that the intended fix would be to allow the user to play the video, rather than hiding the play button entirely and preventing playback. I suspect it will probably take some Javascript to pass the touch/click events through to the lower video layer.
Yes @bhdd, my bad!
You are right, this will set the display of the buttons to none but might not guarantee that the video will autoplay or not
Yes, that could be a possible solution 👍
Replicating it on local WordPress setup with all the low power mode is little daunting, lmk if there is a solution to it
My understanding, after doing more reading, is that user agent shadow DOM elements aren't accessible via Javascript. Given that it's the browser adding the play button based on detection of low-power mode, I suspect that it won't be possible to get the coordinates of the play button (in the shadow DOM) and pass the touch/click events from the top layer to the lower video layer. The layer order can't be adjusted given the nature of the elements on each, so I can't think of a path to a solution at this time.
Hi, This issue has gone 30 days without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest versions, you can help the project by responding to confirm the problem and by providing any updated reproduction steps. Thanks for helping out.
I can reproduce the issue with Browser Stack using IOS 17 in low power mode. As mentioned by @bhdd we can't play the video due to span tag blocking the click events.
It can be fixed by adding pointer-events: none; to the span.
https://github.com/WordPress/gutenberg/blob/bdb16796eb85051b9d5d7b00fcb773973642a5e7/packages/block-library/src/cover/style.scss#L49-L58
However, if the Cover Block contains inner elements, they can still block clicks if positioned exactly over the video buttons. And I don't think it's a good idea to apply pointer-events: none; to .wp-block-cover__inner-container.
If user use low power mode and the video tag in html has auto play true the auto play is not respected . At least this what I remember , in this case js is needed to trigger the play method of the video dom element
Looked into an old project where I resolved this... When iOS blocks the auto play of the video , the video dom element trigger a "suspend" event.
You can listen to it and do video play (hoping the browser allows you to do it). In case not , the rationale is "only user can intentionally play a video" so a play button is necessary.
Thanks, @\tresorama , for the details. The pointer-events: none on the overlay at least allows the user to play the video if it's not auto-played. Using JS to auto-play is a good idea, as it would avoid cases like a cover block with inner elements, which can also prevent clicks. I will check on it."
Hi, This issue has gone 30 days without any activity. This means it is time for a check-in to make sure it is still relevant. If you are still experiencing this issue with the latest versions, you can help the project by responding to confirm the problem and by providing any updated reproduction steps. Thanks for helping out.
== Reproduction Report This report validates that the issue can be reproduced.
=== Environment
- OS: Android 16
- Web Server: Nginx
- PHP: 7.4.29
- WordPress: 6.0-RC1-53341-src
- Browser: Chrome
- Theme: Twenty Twenty-Four
- Active Plugins:
- Gutenberg 13.2.0
- WordPress Beta Tester 3.2.1
=== Actual Results
- ❌ Error condition didn't occur. - will test again
=== Additional Notes
- Video played fine with and without ultra low power mode
=== Supplemental Artifacts
Add Inline:
Bug Report
Description
When in low power mode (iOS), the background video in a cover block won't play.
Environment
- iOS: 17.6.1
- Safari: 17.6.1
- WordPress: 6.8.2
Steps to Reproduce
- On iPhone, enable Low Power Mode (Settings -> Battery -> Low Power Mode or Control Centre -> Low Power Mode).
- Open Safari and visit a WordPress site with a cover block using a background video (sunrisemovement.org used for testing).
- Observe the browser shows a play button overlay on the video because autoplay is blocked.
- Try to click or tap the play button.
- 🐞 The tap does not work and video cannot be played.
- Turn off the Low Power Mode.
- Refresh the site and the video will autoplay as expected.
Expected Results
- ✅ When tapping the play button overlay on the video, the video should play.
Actual Results
- ❌ Tapping the play button overlay does nothing and the video cannot be played.
Supplemental Artifacts
Example screen recording:
https://github.com/user-attachments/assets/ac0b24d2-0183-498e-ac58-82e3b00a5df5
@Mamaduka since you added the Needs Testing tag and it seems we have a confirmed reproduction here, we can move this from it to Needs Dev.