[wp-trac] [WordPress Trac] #50060: Use playVideo after mute instead of autoplay to prevent video blocking because of autoplay with sound enabled
WordPress Trac
noreply at wordpress.org
Sat May 2 22:11:50 UTC 2020
#50060: Use playVideo after mute instead of autoplay to prevent video blocking
because of autoplay with sound enabled
-----------------------------+-----------------------------
Reporter: olivierblancdev | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Keywords:
Focuses: |
-----------------------------+-----------------------------
Hi,
wp-includes\js\wp-custom-header.js uses autoplay to play video.
When it's a video managed by the NativeHandler, the mute attribute is set
on the creation of the video element, so there is no problem.
But when it's a YouTube video managed by the YouTubeHandler, the YouTube
player is created with the autoplay option active, and the video is muted
on the onReady event of the YouTube player. So it can happend that the
video tries to autoplay before beeing muted, especially with Firefox, then
the video is stopped by the web browser because there is autoplay with
sound enabled.
I propose to use e.target.playVideo() after e.target.mute() instead of
autoplay to prevent the web browser from blocking the Youtube video if the
autoplay starts before e.target.mute() is executed.
Please see https://github.com/WordPress/WordPress/pull/471 with the pull
request to correct the bug with this solution (or attached files).
Best regards,
Olivier Blanc, web developper
--
Ticket URL: <https://core.trac.wordpress.org/ticket/50060>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list