File_OGG extension (was: [oggvorbis])
| From: | Sara Golemon | Date: | Tue, 09 Sep 2003 22:57:40 +0000 |
| Subject: | File_OGG extension (was: [oggvorbis]) | ||
| References: | 1 2 3 4 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-21308@lists.php.net to get a copy of this message | ||
> I didn't plan on having a PECL package to do what your does -- the point
> of File_Ogg and its extending packages for streams such as Vorbis is to
> extract header data. I was hoping to use a PECL package to extract and
> make available the same data. My question was simply to ask if your
> package could be "adapted" to the same goal.
>
Ah... I see, well in terms of extracting the initial header data, the
following code will do that easily:
<?php
$fp = fopen('ogg://songfile.ogg', 'r');
$metadata = stream_get_meta_data($fp);
fclose($fp);
$songdata = $metadata['wrapper_data'][0];
/* $songdata now contains header data */
?>
However, chained OGGs take a bit more code (and I'm not sure if File_Ogg
can handle headers in chained OGGs or not).
<?php
$fp = fopen('ogg://songfile.ogg', 'r');
/* arbitrary chunk size, we just want to scan the whole file */
while (!feof($fp)) fread($fp, 8192);
$metadata = stream_get_meta_data($fp);
fclose($fp);
foreach($metadata['wrapper_data'] as $songdata) {
/* We get a new $songdata for each Vorbis stream in the OGG */
}
?>
Hrmmm... This reminds me, I should trigger a notification event on
encountering a new stream....(For ver 0.3)