[BUGFIX] Add missing functionality for YouTube "related" parameter 17/50317/3
authorTim Rücker <noreply@example.com>
Tue, 27 Sep 2016 13:05:13 +0000 (15:05 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Fri, 21 Oct 2016 13:49:50 +0000 (15:49 +0200)
This parameter indicates whether the player should show
related videos when playback of the initial video ends.
Supported values are 0 and 1. The default value is 1.

Releases: master,7.6
Resolves: #77710
Change-Id: I95576369b8dae579b39298095024bdbddc75ebc6
Reviewed-on: https://review.typo3.org/50317
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/core/Classes/Resource/Rendering/YouTubeRenderer.php
typo3/sysext/core/Tests/Unit/Resource/Rendering/YouTubeRendererTest.php

index 396fe7f..f0e1b88 100644 (file)
@@ -115,6 +115,9 @@ class YouTubeRenderer implements FileRendererInterface
         if (!empty($options['loop'])) {
             $urlParams[] = 'loop=1&amp;playlist=' . $videoId;
         }
+        if (isset($options['relatedVideos'])) {
+            $urlParams[] = 'rel=' . (int)(bool)$options['relatedVideos'];
+        }
         if (!isset($options['enablejsapi']) || !empty($options['enablejsapi'])) {
             $urlParams[] = 'enablejsapi=1&amp;origin=' . GeneralUtility::getIndpEnv('TYPO3_REQUEST_HOST');
         }
index 49de7e9..59c14c5 100644 (file)
@@ -149,7 +149,7 @@ class YouTubeRendererTest extends UnitTestCase
     /**
      * @test
      */
-    public function renderOutputWithAutoplayAndWithoutControllsIsCorrect()
+    public function renderOutputWithAutoplayAndWithoutControlsIsCorrect()
     {
         /** @var File|\PHPUnit_Framework_MockObject_MockObject $fileResourceMock */
         $fileResourceMock = $this->getMock(File::class, [], [], '', false);
@@ -159,4 +159,18 @@ class YouTubeRendererTest extends UnitTestCase
             $this->subject->render($fileResourceMock, '300m', '200', ['controls' => 0, 'autoplay' => 1])
         );
     }
+
+    /**
+     * @test
+     */
+    public function renderOutputWithRelatedVideosTurnedOffIsCorrect()
+    {
+        /** @var File|\PHPUnit_Framework_MockObject_MockObject $fileResourceMock */
+        $fileResourceMock = $this->getMock(File::class, [], [], '', false);
+
+        $this->assertSame(
+            '<iframe src="https://www.youtube.com/embed/7331?autohide=1&amp;controls=2&amp;rel=0&amp;enablejsapi=1&amp;origin=http://test.server.org&amp;showinfo=0" allowfullscreen width="300" height="200"></iframe>',
+            $this->subject->render($fileResourceMock, '300m', '200', ['relatedVideos' => 0])
+        );
+    }
 }