Video::getEmbedUrl()
\nn\t3::Video()->getEmbedUrl($type, $videoId = NULL);
Return the embed URL based on the streaming platform. Classically, the URL that is used in the src attribute of the is used.
\nn\t3::Video()->getEmbedUrl( 'youtube', 'nShlloNgM2E' );
\nn\t3::Video()->getEmbedUrl( 'https://www.youtube.com/watch?v=wu55ZG97zeI&feature=youtu.be' );
Copied!
Also exists as ViewHelper:
{my.videourl->nnt3:video.embedUrl()}
Copied!
| @return string
Source Code
public function getEmbedUrl ($type, $videoId = null)
{
if (!$videoId && strpos($type, 'http') !== false) {
$infos = $this->isExternal( $type );
return $infos['embedUrl'];
}
switch ($type) {
case 'youtube':
return 'https://www.youtube-nocookie.com/embed/'.$videoId;
case 'vimeo':
return 'https://player.vimeo.com/video/'.$videoId;
}
}
Copied!