Autor Zpráva
B8xer
Profil *
Cau, vytiahol som s youtube api cas prekonvertoval ale on neni presny ukazujem nekedy aj 30 sekund viac menej ... na jednom webe som to videl autommaticke a bolo to presne tu je moj kod
<?php
$sxml = simplexml_load_file('http://gdata.youtube.com/feeds/api/videos/EPGMc1EQKpU');
$media = $sxml->children('http://search.yahoo.com/mrss/');
$yt   = $media->children('http://gdata.youtube.com/schemas/2007');
$attr1 = $media->group->thumbnail[0]->attributes();
$thumbnail  = $attr1['url']; 
$attr2 = $yt->duration->attributes();
$length  = $attr2['seconds']; 
$dur = round($length/60,2); 
echo $dur
?>
B8xer
Profil *
Vyreseno
<?php
$id = '8VusUgClhQE';
$sxml = simplexml_load_file('http://gdata.youtube.com/feeds/api/videos/'.$id);
$media = $sxml->children('http://search.yahoo.com/mrss/');
$yt   = $media->children('http://gdata.youtube.com/schemas/2007');
$attr1 = $media->group->thumbnail[0]->attributes();
$thumbnail  = $attr1['url']; // Url
$attr2 = $yt->duration->attributes();
$length  = $attr2['seconds']; // Ziskanie sekund
$video_duration = floor($length/60) . ":" . $length % 60;//ziskanie minut
echo $video_duration;//Vypisem
?>

Vaše odpověď

Mohlo by se hodit


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm:

0