RE: [PECL-DEV] [Proposal] id3v1
| From: | Wez Furlong | Date: | Sun, 06 Jun 2004 15:55:10 +0000 |
| Subject: | RE: [PECL-DEV] [Proposal] id3v1 | ||
| References: | 1 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-731@lists.php.net to get a copy of this message | ||
> OK. Should I also rename the functions to reflect the
> extension name or
> should I later add id3v2_get_tag()?
That depends; can v1 and v2 tags coexist in the same file?
If yes, then perhaps something like this is future proof (psuedo code):
define('ID3_V1', 1);
define('ID3_V2', 2);
$tag1 = id3_get_tag($filename, ID3_V1); // get v1 tag
$tag2 = id3_get_tag($filename, ID3_V2); // get v2 tag
This allows your code to support later versions too.
If it makes sense, you could also define ID3_BEST or something similar to
retrieve the "best", most descriptive tag that is present, so:
$tag = id3_get_tag($filename, ID3_BEST);
Would be equivalent to:
$tag = id3_get_tag($filename, ID3_V2);
if (!$tag) {
$tag = id3_get_tag($filename, ID3_V1);
}
> That would require the user to always pass an array, when
> updating ID3
> information. I'm not sure, whether this is nice for the user,
> although
> it would make my life easier :)
$tag = array('title'=>....);
id3_set_tag($filename, ID3_V1, $tag);
This is easy enough for me ;-)
> One question: is it possible to store information in a stream
> structure?
> I thought I once read of stream->abstract or something like
> this... I'd
> like to store the version information once I've retrieved it and this
> would be an easy way to do it...
No, stream->abstract is private to the stream implementation and there is no
way to stash your own data into a stream, unless you write a wrapper, and that
doesn't really make sense here.
What would be really nice is the overload the $filename parameter to accept
either a string representing the filename, or an already opened stream
resource. You could then eliminate the _open() and _close() functions and not
worry about managing resources at all :-)
--Wez.