Skip to content
Snippets Groups Projects
Commit 8c8cc091 authored by Georg Ringer's avatar Georg Ringer Committed by Christian Kuhn
Browse files

[BUGFIX] Set mute=1 if autoplay=1 for rendering youtube videos

The option "autoplay" only works if "mute" is enabled. See
https://developer.chrome.com/blog/autoplay/ for reference.

Resolves: #96320
Releases: main, 11.5, 10.4
Change-Id: Ic4e2de0576fe3d1619af8e35274adeb013c72b31
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72846


Tested-by: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
parent b83a4c04
Branches
Tags
No related merge requests found
......@@ -142,6 +142,8 @@ class YouTubeRenderer implements FileRendererInterface
$urlParams[] = 'controls=' . $options['controls'];
if (!empty($options['autoplay'])) {
$urlParams[] = 'autoplay=1';
// If autoplay is enabled, enforce mute=1, see https://developer.chrome.com/blog/autoplay/
$urlParams[] = 'mute=1';
}
if (!empty($options['modestbranding'])) {
$urlParams[] = 'modestbranding=1';
......
......@@ -109,7 +109,7 @@ class YouTubeRendererTest extends UnitTestCase
$fileResourceMock = $this->createMock(File::class);
self::assertSame(
'<iframe src="https://www.youtube-nocookie.com/embed/7331?autohide=1&amp;controls=1&amp;autoplay=1&amp;enablejsapi=1&amp;origin=http%3A%2F%2Ftest.server.org" allowfullscreen width="300" height="200" allow="autoplay; fullscreen"></iframe>',
'<iframe src="https://www.youtube-nocookie.com/embed/7331?autohide=1&amp;controls=1&amp;autoplay=1&amp;mute=1&amp;enablejsapi=1&amp;origin=http%3A%2F%2Ftest.server.org" allowfullscreen width="300" height="200" allow="autoplay; fullscreen"></iframe>',
$this->subject->render($fileResourceMock, '300m', '200', ['controls' => 1, 'autoplay' => 1])
);
}
......@@ -128,7 +128,7 @@ class YouTubeRendererTest extends UnitTestCase
$fileReferenceMock->expects(self::any())->method('getOriginalFile')->willReturn($fileResourceMock);
self::assertSame(
'<iframe src="https://www.youtube-nocookie.com/embed/7331?autohide=1&amp;controls=1&amp;autoplay=1&amp;enablejsapi=1&amp;origin=http%3A%2F%2Ftest.server.org" allowfullscreen width="300" height="200" allow="autoplay; fullscreen"></iframe>',
'<iframe src="https://www.youtube-nocookie.com/embed/7331?autohide=1&amp;controls=1&amp;autoplay=1&amp;mute=1&amp;enablejsapi=1&amp;origin=http%3A%2F%2Ftest.server.org" allowfullscreen width="300" height="200" allow="autoplay; fullscreen"></iframe>',
$this->subject->render($fileReferenceMock, '300m', '200', ['controls' => 1])
);
}
......@@ -142,7 +142,7 @@ class YouTubeRendererTest extends UnitTestCase
$fileResourceMock = $this->createMock(File::class);
self::assertSame(
'<iframe src="https://www.youtube-nocookie.com/embed/7331?autohide=1&amp;controls=0&amp;autoplay=1&amp;enablejsapi=1&amp;origin=http%3A%2F%2Ftest.server.org" allowfullscreen width="300" height="200" allow="autoplay; fullscreen"></iframe>',
'<iframe src="https://www.youtube-nocookie.com/embed/7331?autohide=1&amp;controls=0&amp;autoplay=1&amp;mute=1&amp;enablejsapi=1&amp;origin=http%3A%2F%2Ftest.server.org" allowfullscreen width="300" height="200" allow="autoplay; fullscreen"></iframe>',
$this->subject->render($fileResourceMock, '300m', '200', ['controls' => 0, 'autoplay' => 1])
);
}
......@@ -339,7 +339,7 @@ class YouTubeRendererTest extends UnitTestCase
$fileResourceMock = $this->createMock(File::class);
self::assertSame(
'<iframe src="https://www.youtube-nocookie.com/embed/7331?autohide=1&amp;controls=0&amp;autoplay=1&amp;enablejsapi=1&amp;origin=http%3A%2F%2Ftest.server.org" allowfullscreen width="300" height="200" allow="foo; bar"></iframe>',
'<iframe src="https://www.youtube-nocookie.com/embed/7331?autohide=1&amp;controls=0&amp;autoplay=1&amp;mute=1&amp;enablejsapi=1&amp;origin=http%3A%2F%2Ftest.server.org" allowfullscreen width="300" height="200" allow="foo; bar"></iframe>',
$this->subject->render($fileResourceMock, '300m', '200', ['controls' => 0, 'autoplay' => 1, 'allow' => 'foo; bar'])
);
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment