[BUGFIX] Fix requiring playlist argument when "loop" is set 76/50076/4
authorWouter Wolters <typo3@wouterwolters.nl>
Fri, 30 Sep 2016 12:06:38 +0000 (14:06 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Thu, 6 Oct 2016 14:29:15 +0000 (16:29 +0200)
The YouTubeRenderer does not force the playlist argument yet
when the loop argument is set to 1. According to the documentation
this is required for a single video player. See
https://developers.google.com/youtube/player_parameters#loop

Resolves: #78053
Releases: master,7.6
Change-Id: Ife89cce318347aa6fa1694b90c71d9931538aa4e
Reviewed-on: https://review.typo3.org/50076
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
typo3/sysext/core/Classes/Resource/Rendering/YouTubeRenderer.php
typo3/sysext/core/Tests/Unit/Resource/Rendering/YouTubeRendererTest.php

index 9ecff66..396fe7f 100644 (file)
@@ -97,6 +97,14 @@ class YouTubeRenderer implements FileRendererInterface
             }
         }
 
+        if ($file instanceof FileReference) {
+            $orgFile = $file->getOriginalFile();
+        } else {
+            $orgFile = $file;
+        }
+
+        $videoId = $this->getOnlineMediaHelper($file)->getOnlineMediaId($orgFile);
+
         $urlParams = ['autohide=1'];
         if (!isset($options['controls']) || !empty($options['controls'])) {
             $urlParams[] = 'controls=2';
@@ -105,20 +113,13 @@ class YouTubeRenderer implements FileRendererInterface
             $urlParams[] = 'autoplay=1';
         }
         if (!empty($options['loop'])) {
-            $urlParams[] = 'loop=1';
+            $urlParams[] = 'loop=1&amp;playlist=' . $videoId;
         }
         if (!isset($options['enablejsapi']) || !empty($options['enablejsapi'])) {
             $urlParams[] = 'enablejsapi=1&amp;origin=' . GeneralUtility::getIndpEnv('TYPO3_REQUEST_HOST');
         }
         $urlParams[] = 'showinfo=' . (int)!empty($options['showinfo']);
 
-        if ($file instanceof FileReference) {
-            $orgFile = $file->getOriginalFile();
-        } else {
-            $orgFile = $file;
-        }
-
-        $videoId = $this->getOnlineMediaHelper($file)->getOnlineMediaId($orgFile);
         $src = sprintf(
             'https://www.youtube%s.com/embed/%s?%s',
             !empty($options['no-cookie']) ? '-nocookie' : '',
index f740a26..0e3eeb5 100644 (file)
@@ -108,7 +108,7 @@ class YouTubeRendererTest extends UnitTestCase
         $fileResourceMock = $this->createMock(File::class);
 
         $this->assertSame(
-            '<iframe src="https://www.youtube.com/embed/7331?autohide=1&amp;controls=2&amp;loop=1&amp;enablejsapi=1&amp;origin=http://test.server.org&amp;showinfo=0" allowfullscreen width="300" height="200"></iframe>',
+            '<iframe src="https://www.youtube.com/embed/7331?autohide=1&amp;controls=2&amp;loop=1&amp;playlist=7331&amp;enablejsapi=1&amp;origin=http://test.server.org&amp;showinfo=0" allowfullscreen width="300" height="200"></iframe>',
             $this->subject->render($fileResourceMock, '300m', '200', ['loop' => 1])
         );
     }