class YouTube {
//recoge el id del video
function _GetVideoIdFromUrl($url) {
$parts = explode('?v=',$url);
if (count($parts) == 2) {
$tmp = explode('&',$parts[1]);
if (count($tmp)>1) {
return $tmp[0];
} else {
return $parts[1];
}
} else {
return $url;
}
}
// muestra el video embedido
function EmbedVideo($videoid,$width = 425,$height = 350) {
$videoid = $this->_GetVideoIdFromUrl($videoid);
return '';
}
//recoge la url de la imagen del video
function GetImg($videoid,$imgid = 1) {
$videoid = $this->_GetVideoIdFromUrl($videoid);
return "http://img.youtube.com/vi/$videoid/$imgid.jpg";
}
//muestra la imagen
function ShowImg($videoid,$imgid = 1,$alt = 'Captura de video') {
return "";
}
}
aca probe este codigo con mi video favorito by the way pero funcionan los numeros del 0 al 3 tengan en cuenta esto cuando almacenen en alguna base de datos modifiquen el nombre, me refiero a esto.http://img.youtube.com/vi/JnfyjwChuNU/0.jpg
http://img.youtube.com/vi/JnfyjwChuNU/1.jpg
http://img.youtube.com/vi/JnfyjwChuNU/2.jpg
http://img.youtube.com/vi/JnfyjwChuNU/3.jpg
si graban del hacia delante les aparecera esta imagen.
espero les haya servido el truquito y la explicacion Namaste :)






0 comentarios:
Publicar un comentario