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!

Comments

Posted on by khen
khen

Warning: Missing argument 1 for ID3Lib::__construct(), called in D:\yoursol\music\mp3\length.php on line 5 and defined in D:\yoursol\music\mp3\id3lib.php on line 16

Warning: fopen() [function.fopen]: Filename cannot be empty in D:\yoursol\music\mp3\id3lib.php on line 20

Title:

Artist:

Album:

Track Number:

Disc:

Year:

Genre:

Length: 0:00

Avg. Bit Rate:

Reply
Posted on by Namit Khullar
Namit Khullar

Hey, I was just wondering if we can also write permanently to these files. Like changing their tags, not just displaying them.

Please do help.

The above code works fine. Thanks.

Reply
Posted on by dxprog
dxprog

There currently is no write support for writing ID3 in my library. I'll see what I can do about working it in.

Reply

Post A Comment

AvatarLogin with FacebookLogin with Twitter