Pulling in mp3 library folder
Posted By Thaylin on October 27, 2008
So I have a client who wanted to have mp3’s that the user could listen to and also download. Since I’m very against having to constantly manage a clients content I wanted him to be able to have no problem adding and removing mp3 files. Normally, one might have an xml file that the user can update but that’s to prone to fail on the side of the client. So what to do…
Enter getId3. This is a super handy tool for anyone who would want to retrieve data about mp3 files via php. Granted, php isn’t that fastest and I have yet to test the speed of retrieval on a large scale, but as of now it seems to be a superb way to automatically generate my listing of mp3 files along with the data attributed to them.
Here is my php file I created to give you an idea of what it can do:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | require_once('../../../getid3/getid3/getid3.php'); echo "\n\n"; // include getID3() library (can be in a different directory if full path is specified) // Initialize getID3 engine $getID3 = new getID3; $DirectoryToScan = '../mp3'; // change to whatever directory you want to scan $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); // output desired information in whatever format you want echo "\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\t\n"; echo "\t\n"; } } echo "\n"; |
And here is my result
1 2 3 4 5 6 7 8 9 10 11 12 | <music> <song url="bobSong.mp3" length = "3:50" bitrate = "160 kbps"> <songartist><![CDATA[Bob]]></songartist> <songtitle><![CDATA[Bobs awesome song]]></songtitle> <songalbum><![CDATA[Bobs Awesome Album]]></songalbum> </song> <song url="bobSongTwo.mp3" length = "3:50" bitrate = "160 kbps"> <songartist><![CDATA[Bob]]></songartist> <songtitle><![CDATA[Bobs awesome remix]]></songtitle> <songalbum><![CDATA[Bobs Awesome Album]]></songalbum> </song> </music> |
Buy:Mega Hoodia.Human Growth Hormone.Zyban.Valtrex.Actos.Prednisolone.Petcam (Metacam) Oral Suspension.Retin-A.Nexium.Accutane.Lumigan.Prevacid.Zovirax.Arimidex.100% Pure Okinawan Coral Calcium.Synthroid….
Buy:Mega Hoodia.Nexium.Arimidex.Human Growth Hormone.Accutane.Zovirax.Prevacid.Zyban.100% Pure Okinawan Coral Calcium.Petcam (Metacam) Oral Suspension.Prednisolone.Actos.Retin-A.Valtrex.Lumigan.Synthroid….