Re: Regarding Accesing mp3 with php

From: Date: Fri, 26 Jun 2009 14:55:43 +0000
Subject: Re: Regarding Accesing mp3 with php
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-294649@lists.php.net to get a copy of this message
2009/6/26 Gautam Bhatia <mail2gautambhatia@gmail.com>: > 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']) : '&nbsp;') . " - "; echo (!empty($ThisFileInfo['comments_html']['title']) ? implode('<BR>', $ThisFileInfo['comments_html']['title']) : '&nbsp;'); echo " (" . (!empty($ThisFileInfo['audio']['bitrate']) ? round($ThisFileInfo['audio']['bitrate'] / 1000).' kbps' : '&nbsp;') . ") - "; echo (!empty($ThisFileInfo['playtime_string']) ? $ThisFileInfo['playtime_string'] : '&nbsp;') . " - "; 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.

« previous php.general (#294649) next »