Add write support for ID3v2 frames

git-svn-id: http://php-reader.googlecode.com/svn/trunk@65 51a70ab9-7547-0410-9469-37e369ee0574
This commit is contained in:
svollbehr
2008-04-02 15:22:46 +00:00
parent 458335dc9f
commit ad6a722bae
88 changed files with 1857 additions and 337 deletions

View File

@@ -57,7 +57,7 @@ final class ID3_Frame_POSS extends ID3_Frame
implements ID3_Timing
{
/** @var integer */
private $_format;
private $_format = 1;
/** @var string */
private $_position;
@@ -67,12 +67,15 @@ final class ID3_Frame_POSS extends ID3_Frame
*
* @param Reader $reader The reader object.
*/
public function __construct($reader)
public function __construct($reader = null)
{
parent::__construct($reader);
if ($reader === null)
return;
$this->_format = ord($this->_data{0});
$this->_position = Transform::fromInt32BE(substr($this->_data, 1, 4));
$this->_format = Transform::fromInt8($this->_data[0]);
$this->_position = Transform::fromUInt32BE(substr($this->_data, 1, 4));
}
/**
@@ -82,6 +85,14 @@ final class ID3_Frame_POSS extends ID3_Frame
*/
public function getFormat() { return $this->_format; }
/**
* Sets the timing format.
*
* @see ID3_Timing
* @param integer $format The timing format.
*/
public function setFormat($format) { $this->_format = $format; }
/**
* Returns the position where in the audio the listener starts to receive,
* i.e. the beginning of the next frame.
@@ -89,4 +100,31 @@ final class ID3_Frame_POSS extends ID3_Frame
* @return integer
*/
public function getPosition() { return $this->_position; }
/**
* Sets the position where in the audio the listener starts to receive,
* i.e. the beginning of the next frame, using given format.
*
* @param integer $position The position.
* @param integer $format The timing format.
*/
public function setPosition($position, $format = false)
{
$this->_position = $position;
if ($format !== false)
$this->_format = $format;
}
/**
* Returns the frame raw data.
*
* @return string
*/
public function __toString()
{
$this->setData
(Transform::toInt8($this->_format) .
Transform::toUInt32($this->_position));
return parent::__toString();
}
}