Problem/Motivation

Youtube videos won't autoplay unless you configure sound to mute

Steps to reproduce

In field display, you can configure autoplay and responsive option

Proposed resolution

I propose to add a checkbox with mute option or simply add 'mute' => '1' in case autoplay is checked

This code is visible in src/plugin/video_embed_field/Provide/YouTube.php


public function renderEmbedCode($width, $height, $autoplay) {
    $embed_code = [
      '#type' => 'video_embed_iframe',
      '#provider' => 'youtube',
      '#url' => sprintf('https://www.youtube.com/embed/%s', $this->getVideoId()),
      '#query' => [
        'autoplay' => $autoplay,
        'start' => $this->getTimeIndex(),
        'rel' => '0',
        'mute' => '1',
      ],
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

creatile created an issue. See original summary.

naveenvalecha’s picture

StatusFileSize
new506 bytes
kevinn’s picture

StatusFileSize
new524 bytes

Your patch is forcing mute, i created a patch where mute is enabled if autoplay is.

bobi-mel made their first commit to this issue’s fork.

bobi-mel’s picture

Version: 8.x-2.4 » 8.x-2.x-dev
Assigned: creatile » Unassigned
Status: Active » Needs review
StatusFileSize
new524 bytes

The patches #2 and #3 can't be applied for D10. I added a new patch and created the MR.

o_timoshchuk’s picture

Status: Needs review » Reviewed & tested by the community

I checked the patch #6 and it worked for me

nicxvan made their first commit to this issue’s fork.

nicxvan’s picture

Simplified the patch a bit.

nicxvan’s picture

Title: Video autoplay » Youtube Video autoplay

mably made their first commit to this issue’s fork.

  • mably committed 1ab482d3 on 3.0.x authored by bobi-mel
    Issue #3192736 by bobi-mel, nicxvan, naveenvalecha, kevinn: Youtube...
mably’s picture

Status: Reviewed & tested by the community » Fixed

  • mably committed f4d39a20 on 8.x-2.x authored by bobi-mel
    Issue #3192736 by bobi-mel, nicxvan, naveenvalecha, kevinn: Youtube...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

nicxvan’s picture