Check ID3 version?

Locked
nnhubbard
User
Posts: 22
Joined: Fri Dec 19, 2008 5:20 am

Check ID3 version?

Post by nnhubbard » Fri Dec 19, 2008 5:43 pm

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?

James Heinrich
getID3() v1 developer
Posts: 1477
Joined: Fri May 04, 2001 4:00 pm
Are you a spambot?: no
Location: Northern Ontario, Canada
Contact:

Re: Check ID3 version?

Post by James Heinrich » Sat Dec 20, 2008 12:41 am

...?
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

nnhubbard
User
Posts: 22
Joined: Fri Dec 19, 2008 5:20 am

Re: Check ID3 version?

Post by nnhubbard » Sat Dec 20, 2008 12:44 am

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?

nnhubbard
User
Posts: 22
Joined: Fri Dec 19, 2008 5:20 am

Re: Check ID3 version?

Post by nnhubbard » Sat Dec 20, 2008 12:51 am

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!

Locked