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
- include('id3lib.php');
- $songs = array('song1.mp3', 'song2.mp3', 'song3.mp3');
- $id3 = new ID3Lib();
- for ($i = 0, $count = count($songs); i < $count; i++) {
- $id3->readFile;
- $min = floor($id3->length / 60);
- $sec = $id3->length - ($min * 60);
- $sec = strlen($sec) == 1 ? '0' . $sec : $sec;
- echo 'Title: ', $id3->title, '<br />';
- echo 'Artist: ', $id3->artist, '<br />';
- echo 'Album: ', $id3->album, '<br />';
- echo 'Track Number: ', $id3->track, '<br />';
- echo 'Disc: ', $id3->disc, '<br />';
- echo 'Year: ', $id3->year, '<br />';
- echo 'Genre: ', $id3->genre, '<br />';
- echo 'Length: ', $min, ':', $sec, '<br />';
- echo 'Avg. Bit Rate: ', $id3->bitrate, '<br />';
- $id3->savePicture($i.'_pic.jpg');
- }
- ?>
If you have any comments/issues, let me know!
Comments
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@khen I think that version required a filename on the constructor. Try the latest version and let me know if you have any issues: http://dxprog.com/files/id3lib_20110412.zip
ReplyHey, 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.
ReplyThere currently is no write support for writing ID3 in my library. I'll see what I can do about working it in.
Reply