WordPress.org

Make WordPress Core

Opened 7 months ago

Last modified 7 months ago

#50060 new defect (bug)

Use playVideo after mute instead of autoplay to prevent video blocking because of autoplay with sound enabled

Reported by: olivierblancdev Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Customize Keywords:
Focuses: Cc:

Description

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

Attachments (2)

wp-custom-header.js (10.7 KB) - added by olivierblancdev 7 months ago.
wp-includes\js\wp-custom-header.js
wp-custom-header.min.js (4.4 KB) - added by olivierblancdev 7 months ago.
wp-includes\js\wp-custom-header.min.js

Download all attachments as: .zip

Change History (3)

@olivierblancdev
7 months ago

wp-includes\js\wp-custom-header.js

@olivierblancdev
7 months ago

wp-includes\js\wp-custom-header.min.js

#1 @SergeyBiryukov
7 months ago

  • Component changed from General to Customize
Note: See TracTickets for help on using tickets.