/** * Create the HTML to embed the video and return it. * * @param string $url The YouTube url belonging to the video you want to show * @return string The HTML to embed the video or an empty string if the url is not found */ public static function getEmbedHTML($url) { Logger::log("Enter: YouTube::getEmbedHTML | Arg: \$url = {$url}"); $html = ''; $youtube = new YouTube(); $videoID = $youtube->parseVideoID($url); if ($videoID !== null) { $entry = $youtube->getVideoEntry($videoID); if ($entry !== null) { $videoTitle = $entry->mediaGroup->title; $videoUrl = $youtube->findFlashUrl($entry); $description = $entry->mediaGroup->description; if ($videoUrl !== null) { if ($videoTitle !== null && $videoTitle !== '') { $html .= '<p class="video-title"><a href="' . $videoUrl . '">' . $videoTitle . '</a></p>' . "\n"; } else { $html .= '<p class="video-title"><a href="' . $videoUrl . '">View video on YouTube</a></p>' . "\n"; } $html .= '<p class="video-link">' . $videoUrl . '</p>' . "\n"; $html .= '<object width="300" height="180">'; $html .= "\t" . '<param name="movie" value="' . $videoUrl . '"></param>' . "\n"; $html .= "\t" . '<param name="allowFullScreen" value="true"></param>' . "\n"; $html .= "\t" . '<param name="allowscriptaccess" value="always"></param>' . "\n"; $html .= "\t" . '<param name="wmode" value="opaque"></param>' . "\n"; $html .= "\t" . '<embed src="' . $videoUrl . '" type="application/x-shockwave-flash"' . "\n"; $html .= "\t\t" . 'allowscriptaccess="always" allowfullscreen="true" wmode="opaque" width=425" height="350"></embed>' . "\n"; $html .= '</object>' . "\n"; $html .= '<p class="video-description">' . $description . '</p>' . "\n"; } } } Logger::log("Exit: YouTube::getEmbedHTML"); return $html; }