Page 1 of 1

Check ID3 version?

Posted: Fri Dec 19, 2008 5:43 pm
by nnhubbard
Is it possible to check the ID3 versions so that I can write tags for v1 if that is the kind that is found? Is this possible?

Re: Check ID3 version?

Posted: Sat Dec 20, 2008 12:41 am
by James Heinrich
...?
If ['id3v1'] is present, then it's v1.x (if ['id3v1']['track'] exists, it's v1.1, otherwise it's v1.0)
If ['id3v2'] is present, check ['id3v2']['majorversion'] (one of "2" or "3" or "4") and ['id3v2']['minorversion'] (should be "0"), which would be ID3v2.2 or ID3v2.3 or ID3v2.4

Re: Check ID3 version?

Posted: Sat Dec 20, 2008 12:44 am
by nnhubbard
Ok, I have a working solution, but it still poses a problem:

Code: Select all

$versionCheck = $id3->info['tags']['id3v2'];

if ($versionCheck) {
					if (isset($id3->info['tags']['id3v2']['title'][0])) {
						return $id3->info['tags']['id3v2']['title'][0];
					}
				} else {
					if (isset($id3->info['tags']['id3v1']['title'][0])) {
						return $id3->info['tags']['id3v1']['title'][0];
					}
				}//end else
So, I am checking to see if $id3->info['tags']['id3v2']; returns true, and if it does, I use the id3v2 tags, if not, I use id2v1. But the strange thing is, when I am getting the info on id3v1 tags, it will work correctly, but I still get Undefined index: id3v2 error, which is strange. Why would it be returning that error when working with a id3v1 file?

Re: Check ID3 version?

Posted: Sat Dec 20, 2008 12:51 am
by nnhubbard
Ok, I changed my var to:

Code: Select all

$versionCheck = isset($id3->info['tags']['id3v2']);
To check if it is set, and my error is gone!