|
@@ -39,9 +39,9 @@ class MediaVideo
|
|
|
|
|
|
/**
|
|
|
* @Assert\Regex(
|
|
|
- * pattern="#^(http|https)://(youtu.be|www.youtube.com|www.dailymotion.com|vimeo.com)/#",
|
|
|
+ * pattern="#^(http|https)://(youtu.be|www.youtube.com|www.dailymotion.com|vimeo.com|video.fdlibre.eu)/#",
|
|
|
* match=true,
|
|
|
- * message="L'url doit correspondre à l'url d'une vidéo Youtube, DailyMotion ou Vimeo"
|
|
|
+ * message="L'url doit correspondre à l'url d'une vidéo Youtube, DailyMotion, Vimeo ou Peertube(fdlibre)"
|
|
|
* )
|
|
|
*/
|
|
|
private $url;
|
|
@@ -120,6 +120,14 @@ class MediaVideo
|
|
|
|
|
|
/////////////////////
|
|
|
// Méthodes
|
|
|
+ private function peertubeId($url)
|
|
|
+ {
|
|
|
+ $tableau = explode("/", $url);
|
|
|
+ $id = $tableau[count($tableau)-1];
|
|
|
+ $this->setIdentif($id);
|
|
|
+ $this->setType('peertube');
|
|
|
+ }
|
|
|
+
|
|
|
private function youtubeId($url)
|
|
|
{
|
|
|
$tableaux = explode("=", $url); // découpe l’url en deux avec le signe ‘=’
|
|
@@ -131,7 +139,7 @@ class MediaVideo
|
|
|
private function youtubeCourteId($url)
|
|
|
{
|
|
|
$tableaux = explode("/", $url); // on découpe l’url grâce au « / »
|
|
|
- $id = $tableaux[count($tableaux)-1]; // on reticent la dernière partie qui contient l’identifiant
|
|
|
+ $id = $tableaux[count($tableaux)-1]; // on retient la dernière partie qui contient l’identifiant
|
|
|
$this->setIdentif($id); // ajoute l’identifiant à l’attribut identif
|
|
|
$this->setType('youtube'); // signale qu’il s’agit d’une video youtube et l’inscrit dans l’attribut $type
|
|
|
}
|
|
@@ -164,6 +172,11 @@ class MediaVideo
|
|
|
{
|
|
|
$url = $this->getUrl(); // on récupère l’url
|
|
|
|
|
|
+ if (preg_match("#^(http|https)://video.fdlibre.eu/#", $url)) // Si c'est peertube fdlibre
|
|
|
+ {
|
|
|
+ $this->peertubeId($url);
|
|
|
+ }
|
|
|
+
|
|
|
if (preg_match("#^(http|https)://www.youtube.com/#", $url)) // Si c’est une url Youtube on execute la fonction correspondante
|
|
|
{
|
|
|
$this->youtubeId($url);
|
|
@@ -197,6 +210,9 @@ class MediaVideo
|
|
|
} else if ($control == 'vimeo') {
|
|
|
$embed = "https://player.vimeo.com/video/" . $id;
|
|
|
return $embed;
|
|
|
+ } else if ($control == 'peertube') {
|
|
|
+ $embed = "https://video.fdlibre.eu/videos/embed/" . $id;
|
|
|
+ return $embed;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -214,6 +230,9 @@ class MediaVideo
|
|
|
} else if ($control == 'vimeo') {
|
|
|
$embed = "https://vimeo.com/" . $id;
|
|
|
return $embed;
|
|
|
+ } else if ($control == 'peertube') {
|
|
|
+ $embed = "https://video.fdlibre.eu/videos/watch/" . $id;
|
|
|
+ return $embed;
|
|
|
}
|
|
|
}
|
|
|
|