The playtime of some mp3s are most times put out correct like 3:29.
On some mp3s getID3 appends a millisecond, so 3:295.
Why? How can I get rid of this?
Thanx! :-)
<?php
require_once('js/getid3/getid3.php');
$url=$TrackFileHere.'.mp3';
if($url){
$filename = tempnam('/tmp','getid3');
if (file_put_contents($filename, file_get_contents($url, false, null, 0, 300000))) {
if (require_once('js/getid3/getid3.php')) {
$getID3 = new getID3;
$ThisFileInfo = $getID3->analyze($filename);}
unlink($filename);}}
$bitratez=$ThisFileInfo[audio][bitrate];
$headers = get_headers($url, 1);
if ((!array_key_exists("Content-Length", $headers))) { return false; }
$filesize= round($headers["Content-Length"]/1000);
$contentLengthKBITS=$filesize*8;
$bitrate=$bitratez/1000;
$seconds=$contentLengthKBITS/$bitrate;
$playtime_mins = floor($seconds/60);
$playtime_secs = $seconds % 60;
if(strlen($playtime_secs)=='1'){$zero='0';}
$playtime_secs = $zero.$playtime_secs;
$playtime_string=$playtime_mins.':'.$playtime_secs;
echo $playtime_string;
?>
</td>
<td><?php echo($TrackISRCHere); ?></td>
<td style="text-align: center; font-weight: bold;"><a href="<?php echo($TrackFileHere)?>.mp3">mp3</a>
/ <a href="<?php echo($TrackFileHere)?>.wav">wav</a></td>
</tr>
<?php
}
?>Take out all that, and replace it with:melino wrote:
- Code: Select all
$headers = get_headers($url, 1);
if ((!array_key_exists("Content-Length", $headers))) { return false; }
$filesize= round($headers["Content-Length"]/1000);
$contentLengthKBITS=$filesize*8;
$bitrate=$bitratez/1000;
$seconds=$contentLengthKBITS/$bitrate;
$playtime_mins = floor($seconds/60);
$playtime_secs = $seconds % 60;
if(strlen($playtime_secs)=='1'){$zero='0';}
$playtime_secs = $zero.$playtime_secs;
$playtime_string=$playtime_mins.':'.$playtime_secs;
echo $playtime_string;
echo $ThisFileInfo['playtime_string'];$playtime_mins = floor($seconds/60);
$playtime_secs = $seconds % 60;
if(strlen($playtime_secs)=='1'){$zero='0';}
$playtime_secs = $zero.$playtime_secs;
$playtime_string=$playtime_mins.':'.$playtime_secs;
echo $playtime_string;echo getid3_lib::PlaytimeString($seconds);Return to Support 1.x (resolved)
Users browsing this forum: No registered users and 0 guests