* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @version $Id$ * @todo Setup header is not yet supported */ final class Zend_Media_Vorbis { /** @var Zend_Io_Reader */ private $_reader; /** @var string */ private $_filename = null; /** @var Zend_Media_Vorbis_Header_Identification */ private $_identificationHeader; /** @var Zend_Media_Vorbis_Header_Comment */ private $_commentHeader; /** @var Zend_Media_Vorbis_Header_Setup */ private $_setupHeader; /** * Constructs the Zend_Media_Vorbis class with given file. * * @param string|resource|Zend_Io_Reader $filename The path to the file, * file descriptor of an opened file, or a {@link Zend_Io_Reader} instance. * @throws Zend_Io_Exception if an error occur in stream handling. * @throws Zend_Media_Vorbis_Exception if an error occurs in vorbis bitstream reading. */ public function __construct($filename) { if ($filename instanceof Zend_Io_Reader) { $this->_reader = &$filename; } else { $this->_filename = $filename; require_once('Zend/Io/FileReader.php'); try { $this->_reader = new Zend_Io_FileReader($filename); } catch (Zend_Io_Exception $e) { $this->_reader = null; require_once 'Zend/Media/Vorbis/Exception.php'; throw new Zend_Media_Vorbis_Exception($e->getMessage()); } } $this->_identificationHeader = new Zend_Media_Vorbis_Header_Identification($this->_reader); $this->_commentHeader = new Zend_Media_Vorbis_Header_Comment($this->_reader); $this->_setupHeader = new Zend_Media_Vorbis_Header_Setup($this->_reader); } /** * Returns the identification header. * * @return Zend_Media_Vorbis_Header_Identification */ public function getIdentificationHeader() { return $this->_identificationHeader; } /** * Returns the comment header. * * @return Zend_Media_Vorbis_Header_Comment */ public function getCommentHeader() { return $this->_commentHeader; } /** * Returns the setup header. * * @return Zend_Media_Vorbis_Header_Setup */ public function getSetupHeader() { return $this->_setupHeader; } /** * Magic function so that $obj->value will work. * * @param string $name The field name. * @return mixed */ public function __get($name) { if (method_exists($this, 'get' . ucfirst($name))) { return call_user_func(array($this, 'get' . ucfirst($name))); } else { require_once('Zend/Media/Vorbis/Exception.php'); throw new Zend_Media_Vorbis_Exception('Unknown field: ' . $name); } } }