Jump to content

[SOLVED] ID3 MP3 tag read/write in PHP


s0c0

Recommended Posts

I would like an easy way of reading(writing is a plus) id3 tags. I have googled this and there is no easy way.  PHP.Net has the following site http://us3.php.net/manual/en/ref.id3.php and I see that I have to install PEAR which I have and then install a pecl extension.  I'm not very good with compiling and was wondering if anyone new of a suse yast repository that contains these or at least an RPM?

 

Or perhaps another way of getting id3 tags?

Link to comment
Share on other sites

I'm not sure that this is going to work (this isn't for personal use this is a project/webapp) and furthermore I'm not sure on how to use classes.  I'm sure it's in my php book and I'll research using classes tonight.  If anyone else has ideas please do tell.

Link to comment
Share on other sites

I solved this on my own.

 

Go to the id3 project page [ http://getid3.sourceforge.net/ ] and download the latest stable version.  I downloaded version 1.7.7.  Then extract the files contents to your web servers root folder.  The readme contains the rest of the information .  I was able to pick up the syntax quickly by analyzing the PHP scripts in the demo directory.

 

Here's an example piece of code:

 

<? php

require_once('/srv/www/htdocs/getid3/getid3/getid3.php');

 

$getID3 = new getID3;

$filename = "/srv/www/htdocs/Wu-Tang Clan - Cream.mp3";

$ThisFileInfo = $getID3->analyze($filename);

getid3_lib::CopyTagsToComments($ThisFileInfo);

echo @$ThisFileInfo['comments_html']['artist'][0] ."<br/>";

echo @$ThisFileInfo['tags']['id3v2']['title'][0] ."<br/>";

echo @$ThisFileInfo['audio']['bitrate'] ."<br/>"; 

echo @$ThisFileInfo['playtime_string'] ."<br/>";

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.