2009/6/26 Gautam Bhatia <[email protected]>:
> hello all,
> Is there anyway in php by which i can get the total play
> time of a mp3 , I found some information while doing the google thing
> using some 3rd party plug ins like getID3 but without any luck, Any help
> in this case would be helpful. Thank you.
> Regards,
>
> Gautam Bhatia .
>
>
>
>
I use this and find it very good: http://getid3.sourceforge.net/
Here is some code I'm using on one of my sites.
Bit messy - but it works for me :)
require_once('../public_html/audio/getid3/getid3.php');
function show_audio($type) {
//Set path to audio files
if ($type == "rmx") {
$path = '/audio/productions/remixes/';
$DirectoryToScan = '../public_html/audio/productions/remixes/';
}
elseif ($type == "pro") {
$path = '/audio/productions/original/';
$DirectoryToScan = '../public_html/audio/productions/original/';
}
$getID3 = new getID3;
$dir = opendir($DirectoryToScan);
while (($file = readdir($dir)) !== false) {
$FullFileName = realpath($DirectoryToScan.'/'.$file);
if (is_file($FullFileName)) {
set_time_limit(30);
$ThisFileInfo = $getID3->analyze($FullFileName);
getid3_lib::CopyTagsToComments($ThisFileInfo);
echo (!empty($ThisFileInfo['comments_html']['artist']) ?
implode('<BR>', $ThisFileInfo['comments_html']['artist']) : ' ')
. " - ";
echo (!empty($ThisFileInfo['comments_html']['title']) ?
implode('<BR>', $ThisFileInfo['comments_html']['title']) : ' ');
echo " (" . (!empty($ThisFileInfo['audio']['bitrate']) ?
round($ThisFileInfo['audio']['bitrate'] / 1000).' kbps' : ' ')
. ") - ";
echo (!empty($ThisFileInfo['playtime_string']) ?
$ThisFileInfo['playtime_string'] : ' ')
. " - ";
echo '<a href = "' . $path . $file .
'">Download</a><br>';
}
}
}
Then I simply upload audio files to the right directory and I don't
have to update the page that lists them.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php