Blog

PHP ID3Lib 1.0 Release

Brand spanking new release of the PHP branch of ID3Lib!

[ Download ]

[ Documentation ]

What's new:

- Added support for ID3v1, older ID3v2

- Genre now returned on all tag versions

- Calculates song duration and average bit rate for constant (CBR) and variable (VBR) bit rate files

- Single object instantiation can read more than one file

- Much improved inline documentation (phpDoc style)

- General code clean-up, bug fixes and improved compatibility

Example

Code: php
  1. include('id3lib.php');
  2. $songs = array('song1.mp3', 'song2.mp3', 'song3.mp3');
  3. $id3 = new ID3Lib();
  4. for ($i = 0, $count = count($songs); i < $count; i++) {
  5. $id3->readFile;
  6. $min = floor($id3->length / 60);
  7. $sec = $id3->length - ($min * 60);
  8. $sec = strlen($sec) == 1 ? '0' . $sec : $sec;
  9. echo 'Title: ', $id3->title, '<br />';
  10. echo 'Artist: ', $id3->artist, '<br />';
  11. echo 'Album: ', $id3->album, '<br />';
  12. echo 'Track Number: ', $id3->track, '<br />';
  13. echo 'Disc: ', $id3->disc, '<br />';
  14. echo 'Year: ', $id3->year, '<br />';
  15. echo 'Genre: ', $id3->genre, '<br />';
  16. echo 'Length: ', $min, ':', $sec, '<br />';
  17. echo 'Avg. Bit Rate: ', $id3->bitrate, '<br />';
  18. $id3->savePicture($i.'_pic.jpg');
  19. }
  20. ?>

If you have any comments/issues, let me know!

ID3Lib - A tag library for all seasons

image

ID3Lib [ Download ]

As one may have derived from previous posts, I have a project the uses MP3s quite heavily. As such, retrieving tag data from these is quite an important thing. Having recently migrated my personal server to Windows, I needed a non-Linux variant of my previous tag read. I thought that while I was at it I could add an additional feature, namely saving embedded album art. Unfortunately, I was unable to find any clear directions on how to do so using TagLib, so I created my own library. Three different times. In three different languages. A C++ version, a .NET version and, finally, a PHP version.

Read More