Add Zend_Media_Id3v2 class proposal
git-svn-id: http://php-reader.googlecode.com/svn/branches/zend@153 51a70ab9-7547-0410-9469-37e369ee0574
This commit is contained in:
113
src/Zend/Media/Id3/Frame/Trck.php
Normal file
113
src/Zend/Media/Id3/Frame/Trck.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Media
|
||||
* @subpackage ID3
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once 'Zend/Media/Id3/TextFrame.php';
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
* The <i>Track number/Position in set</i> frame is a numeric string containing
|
||||
* the order number of the audio-file on its original recording. This may be
|
||||
* extended with a '/' character and a numeric string containing the total
|
||||
* number of tracks/elements on the original recording. E.g. '4/9'.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Media
|
||||
* @subpackage ID3
|
||||
* @author Sven Vollbehr <sven@vollbehr.eu>
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
final class Zend_Media_Id3_Frame_Trck extends Zend_Media_Id3_TextFrame
|
||||
{
|
||||
private $_number;
|
||||
private $_total;
|
||||
|
||||
/**
|
||||
* Constructs the class with given parameters and parses object related
|
||||
* data.
|
||||
*
|
||||
* @param Zend_Io_Reader $reader The reader object.
|
||||
* @param Array $options The options array.
|
||||
*/
|
||||
public function __construct($reader = null, &$options = array())
|
||||
{
|
||||
Zend_Media_Id3_Frame::__construct($reader, $options);
|
||||
|
||||
$this->setEncoding(Zend_Media_Id3_Encoding::ISO88591);
|
||||
|
||||
if ($this->_reader === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->_reader->skip(1);
|
||||
$this->setText($this->_reader->readString8($this->_reader->getSize()));
|
||||
@list ($this->_number, $this->_total) = explode("/", $this->getText());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getNumber()
|
||||
{
|
||||
return intval($this->_number);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the number.
|
||||
*
|
||||
* @param integer $number The number.
|
||||
*/
|
||||
public function setNumber($part)
|
||||
{
|
||||
$this->setText
|
||||
($this->_number = strval($part) .
|
||||
($this->_total ? '/' . $this->_total : ''),
|
||||
Zend_Media_Id3_Encoding::ISO88591);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total number.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getTotal()
|
||||
{
|
||||
return intval($this->_total);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the total number.
|
||||
*
|
||||
* @param integer $total The total number.
|
||||
*/
|
||||
public function setTotal($total)
|
||||
{
|
||||
$this->setText
|
||||
(($this->_number ? $this->_number : '?') . "/" .
|
||||
($this->_total = strval($total)),
|
||||
Zend_Media_Id3_Encoding::ISO88591);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user