/** * Generates the fiting embed code for the video * according to its service. * * @param string $media_url * @param int $width * @param int $height * @param bool $autoplay * @return string */ public static function video_embed($media_url, $width = 400, $height = 300, $autoplay = false) { $infos = VideoUtility::prepare_url($media_url); if ($infos['sourcetype'] != 'error') { switch ($infos['sourcetype']) { case 'youtube': if ($autoplay) { $ap = 'true'; } else { $ap = 'false'; } return '<iframe src="http://www.youtube.com/embed/' . $infos['sourceid'] . '?wmode=opaque&autoplay=' . $autoplay . '" width="' . $width . '" height="' . $height . '" frameborder="0"></iframe>'; case 'vimeo': if ($autoplay) { $ap = 'true'; } else { $ap = 'false'; } return '<iframe src="http://player.vimeo.com/video/' . $infos['sourceid'] . '?wmode=transparent&autoplay=' . $autoplay . '" width="' . $width . '" height="' . $height . '" frameborder="0"></iframe>'; case 'metacafe': if ($autoplay) { $ap = 'yes'; } else { $ap = 'no'; } return '<iframe flashVars="playerVars=autoPlay=' . $ap . '" src="' . $infos['media_url'] . '?playerVars=autoPlay=' . $ap . '" width="' . $width . '" height="' . $height . '"</iframe>'; // return '<embed flashVars="playerVars=autoPlay='.$ap.'" src="'.$infos['media_url'].'" width="'.$width.'" height="'.$height.'" wmode="transparent" allowFullScreen="true" allowScriptAccess="always" name="Metacafe_8409457" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>'; // return '<embed flashVars="playerVars=autoPlay='.$ap.'" src="'.$infos['media_url'].'" width="'.$width.'" height="'.$height.'" wmode="transparent" allowFullScreen="true" allowScriptAccess="always" name="Metacafe_8409457" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>'; case 'dailymotion': if ($autoplay) { $ap = '1'; } else { $ap = '0'; } return '<iframe frameborder="0" width="' . $width . '" height="' . $height . '" src="http://www.dailymotion.com/embed/video/' . $infos['sourceid'] . '?autoPlay=' . $autoplay . '"></iframe>'; case 'facebook': // if($autoplay) $ap = '1'; // else $ap = '0'; return '<iframe width="516" height="346" frameborder="0" src="http://www.facebook.com/v/' . $infos['sourceid'] . '"></iframe>'; default: return ' <object type="application/x-shockwave-flash" data="' . $infos['media_url'] . '?wmode=transparent" width="' . $width . '" height="' . $height . '"> <param name="movie" value="' . $infos['media_url'] . '"/> <param name="wmode" value="opaque" /> <param name="allowfullscreen" value="true" /><span name="allowscriptaccess" value="always"/> </object>'; } } }
function php($data) { $valid = parent::php($data); if ($data['VideoType'] == 'Embed') { if ($data['VideoAddress'] != '') { if (VideoUtility::validate_video($data['VideoAddress']) == false) { $this->validationError("VideoError", _t('Video_Validator.ADDRESS_ERROR', 'Please enter a valid Video URL')); $valid = false; } } else { $this->validationError("VideoError", _t('Video_Validator.ADDRESS_REQUIRED', 'Video URL is required for Embeded videos')); $valid = false; } } if ($data['VideoType'] == 'File') { $videofile = $data['VideoFile']; if ($data['VideoFile'] == '') { $this->validationError("VideoError", _t('Video_Validator.VIDEOFILE_REQUIRED', 'Video File is required for File videos')); $valid = false; } } return $valid; }