From fe129bbb5edff2f643f3d1fba9549b97bb4c04bf Mon Sep 17 00:00:00 2001
From: Steffen Ritter <info@rs-websystems.de>
Date: Wed, 11 Apr 2012 17:11:24 +0200
Subject: [PATCH] [BUGFIX] Media Element does not play videos with own player
 anymore

Since the rewrite to FlowPlayer and the additions for accessibility
the MEDIA Content Element is not capable anymore, to play videos which
ship their own player.

This especially is the case for Videos which are from YouTube, Vimeo
and other similiar platforms. Looking at the implementation it seems,
that the detection of own players has been removed (accidentilly).

Rebuild this detection to make external video platform links work again.

Change-Id: I963a74aa3e1ab6d2de95ade903470be71af5c2d4
Fixes: #33357
Releases: 6.0, 4.7
Reviewed-on: http://review.typo3.org/10259
Reviewed-by: Susanne Moog
Tested-by: Susanne Moog
Reviewed-by: Steffen Ritter
Tested-by: Steffen Ritter
---
 .../content/class.tslib_content_media.php     | 30 ++++++++++++++++---
 .../css_styled_content/static/constants.txt   |  8 +++--
 .../css_styled_content/static/setup.txt       | 13 ++++----
 3 files changed, 39 insertions(+), 12 deletions(-)

diff --git a/typo3/sysext/cms/tslib/content/class.tslib_content_media.php b/typo3/sysext/cms/tslib/content/class.tslib_content_media.php
index 5b2fefc1b5f1..0959135a8a08 100644
--- a/typo3/sysext/cms/tslib/content/class.tslib_content_media.php
+++ b/typo3/sysext/cms/tslib/content/class.tslib_content_media.php
@@ -185,16 +185,39 @@ class tslib_content_Media extends tslib_content_Abstract {
 			}
 		}
 
-		switch ($renderType) {
-			case 'swf' :
-				$conf[$conf['type'] . '.'] = array_merge((array) $conf['mimeConf.']['swfobject.'][$conf['type'] . '.'], $typeConf);
+		if ($renderType !== 'qt' && $renderType !== 'embed') {
+			if (isset($conf['file']) && (
+					strpos($conf['file'], '.swf') !== FALSE ||
+					(strpos($conf['file'], '://') !== FALSE) && strpos(t3lib_div::getUrl($conf['file'], 2), 'application/x-shockwave-flash') !== false)
+			) {
 				$conf = array_merge((array) $conf['mimeConf.']['swfobject.'], $conf);
+				$conf[$conf['type'] . '.']['player'] = strpos($conf['file'], '://') === FALSE ? 'http://' . $conf['file'] : $conf['file'];
+				$conf['installUrl'] = 'null';
+				$conf['forcePlayer'] = 0;
+				$renderType = 'swf';
+			} elseif (isset($conf['file']) && !isset($conf['caption']) && !isset($conf['sources'])) {
+				$renderType = 'swf';
+				$conf['forcePlayer'] = 1;
+			}
+		}
+
+		switch ($renderType) {
+			case 'flowplayer':
+				$conf[$conf['type'] . '.'] = array_merge((array) $conf['mimeConf.']['flowplayer.'][$conf['type'] . '.'], $typeConf);
+				$conf = array_merge((array) $conf['mimeConf.']['flowplayer.'], $conf);
 				unset($conf['mimeConf.']);
 				$conf['attributes.'] = array_merge((array) $conf['attributes.'], $conf['predefined']);
 				$conf['params.'] = array_merge((array) $conf['params.'], $conf['predefined']);
 				$conf['flashvars.'] = array_merge((array) $conf['flashvars.'], $conf['predefined']);
 				$content = $this->cObj->FLOWPLAYER($conf);
 			break;
+			case 'swf':
+				$conf[$conf['type'] . '.'] = array_merge((array) $conf['mimeConf.']['swfobject.'][$conf['type'] . '.'], $typeConf);
+				$conf = array_merge((array) $conf['mimeConf.']['swfobject.'], $conf);
+				unset($conf['mimeConf.']);
+				$conf['flashvars.'] = array_merge((array) $conf['flashvars.'], $conf['predefined']);
+				$content = $this->cObj->SWFOBJECT($conf);
+			break;
 			case 'qt' :
 				$conf[$conf['type'] . '.'] = array_merge($conf['mimeConf.']['swfobject.'][$conf['type'] . '.'], $typeConf);
 				$conf = array_merge($conf['mimeConf.']['qtobject.'], $conf);
@@ -225,7 +248,6 @@ class tslib_content_Media extends tslib_content_Abstract {
 					$content = $this->cObj->stdWrap($content, $conf['stdWrap.']);
 				}
 		}
-
 		return $content;
 	}
 
diff --git a/typo3/sysext/css_styled_content/static/constants.txt b/typo3/sysext/css_styled_content/static/constants.txt
index 70a6a63ee211..ae44637e42ca 100644
--- a/typo3/sysext/css_styled_content/static/constants.txt
+++ b/typo3/sysext/css_styled_content/static/constants.txt
@@ -120,17 +120,19 @@ styles.content.searchresult {
 
 styles.content.media {
     # cat=content/cMedia/j1; type=; label= Video Player: configure the path to the video player
-  videoPlayer = typo3/contrib/flowplayer/flowplayer-3.2.7.swf
+  videoPlayer = typo3/contrib/flashmedia/flvplayer.swf
     # cat=content/cMedia/j2; type=int+; label= Media Video Width: define the default width for the media video
   defaultVideoWidth = 600
   	# cat=content/cMedia/j3; type=int+; label= Media Video Height: define the default height for the media video
   defaultVideoHeight = 400
     # cat=content/cMedia/j4; type=; label= Audio Player: configure the path to the video player
-  audioPlayer = typo3/contrib/flowplayer/flowplayer-3.2.7.swf
+  audioPlayer = typo3/contrib/flashmedia/player.swf
    	# cat=content/cMedia/j5; type=int+; label= Media Audio Width: define the default width for the media audio
   defaultAudioWidth = 300
     # cat=content/cMedia/j6; type=int+; label= Media Audio Height: define the default height for the media audio
-  defaultAudioHeight = 26
+  defaultAudioHeight = 30
+   	# cat=content/cMedia/j7; type=; label= Flow Player: configure the path to the flow-player
+  flowPlayer = typo3/contrib/flowplayer/flowplayer-3.2.7.swf
 }
 
 styles.content.table {
diff --git a/typo3/sysext/css_styled_content/static/setup.txt b/typo3/sysext/css_styled_content/static/setup.txt
index 88e5d63a3bde..23afb545d862 100644
--- a/typo3/sysext/css_styled_content/static/setup.txt
+++ b/typo3/sysext/css_styled_content/static/setup.txt
@@ -1496,11 +1496,11 @@ tt_content.media {
 			asf = MEDIA
 			class = MEDIA
 			wmv = MEDIA
-			mp3 = SWF
-			mp4 = SWF
-			m4v = SWF
-			swa = SWF
-			flv = SWF
+			mp3 = FLOWPLAYER
+			mp4 = FLOWPLAYER
+			m4v = FLOWPLAYER
+			swa = FLOWPLAYER
+			flv = FLOWPLAYER
 			swf = SWF
 			mov = QT
 			m4v = QT
@@ -1509,6 +1509,9 @@ tt_content.media {
 
 		mimeConf.swfobject < tt_content.swfobject.20
 		mimeConf.qtobject < tt_content.qtobject.20
+		mimeConf.flowplayer < tt_content.swfobject.20
+		mimeConf.flowplayer.audio.player = {$styles.content.media.flowPlayer}
+		mimeConf.flowplayer.video.player = {$styles.content.media.flowPlayer}
 
 	}
 	20.stdWrap {
-- 
GitLab