Fix encoding and one byte field issue
git-svn-id: http://php-reader.googlecode.com/svn/trunk@12 51a70ab9-7547-0410-9469-37e369ee0574
This commit is contained in:
@@ -47,16 +47,16 @@
|
||||
interface ID3_Encoding
|
||||
{
|
||||
/** The ISO-8859-1 encoding. */
|
||||
const ISO88591 = 0x00;
|
||||
const ISO88591 = 0;
|
||||
|
||||
/** The UTF-16 Unicode encoding with BOM. */
|
||||
const UTF16 = 0x01;
|
||||
const UTF16 = 1;
|
||||
|
||||
/** The UTF-16BE Unicode encoding without BOM. */
|
||||
const UTF16BE = 0x02;
|
||||
const UTF16BE = 2;
|
||||
|
||||
/** The UTF-8 Unicode encoding. */
|
||||
const UTF8 = 0x03;
|
||||
const UTF8 = 3;
|
||||
|
||||
/**
|
||||
* Returns the text encoding.
|
||||
|
||||
@@ -67,27 +67,14 @@ final class ID3_Frame_APIC extends ID3_Frame
|
||||
* @var Array
|
||||
*/
|
||||
public static $types = array
|
||||
(0x00 => "Other",
|
||||
0x01 => "32x32 pixels file icon (PNG only)",
|
||||
0x02 => "Other file icon",
|
||||
0x03 => "Cover (front)",
|
||||
0x04 => "Cover (back)",
|
||||
0x05 => "Leaflet page",
|
||||
0x06 => "Media (e.g. label side of CD)",
|
||||
0x07 => "Lead artist/lead performer/soloist",
|
||||
0x08 => "Artist/performer",
|
||||
0x09 => "Conductor",
|
||||
0x0A => "Band/Orchestra",
|
||||
0x0B => "Composer",
|
||||
0x0C => "Lyricist/text writer",
|
||||
0x0D => "Recording Location",
|
||||
0x0E => "During recording",
|
||||
0x0F => "During performance",
|
||||
0x10 => "Movie/video screen capture",
|
||||
0x11 => "A bright coloured fish",
|
||||
0x12 => "Illustration",
|
||||
0x13 => "Band/artist logotype",
|
||||
0x14 => "Publisher/Studio logotype");
|
||||
("Other", "32x32 pixels file icon (PNG only)", "Other file icon",
|
||||
"Cover (front)", "Cover (back)", "Leaflet page",
|
||||
"Media (e.g. label side of CD)", "Lead artist/lead performer/soloist",
|
||||
"Artist/performer", "Conductor", "Band/Orchestra", "Composer",
|
||||
"Lyricist/text writer", "Recording Location", "During recording",
|
||||
"During performance", "Movie/video screen capture",
|
||||
"A bright coloured fish", "Illustration", "Band/artist logotype",
|
||||
"Publisher/Studio logotype");
|
||||
|
||||
/** @var integer */
|
||||
private $_encoding;
|
||||
@@ -113,22 +100,27 @@ final class ID3_Frame_APIC extends ID3_Frame
|
||||
$this->_encoding = substr($this->_data, 0, 1);
|
||||
$this->_mimeType = substr
|
||||
($this->_data, 1, ($pos = strpos($this->_data, "\0", 1)) - 1);
|
||||
$this->_pictureType = substr($this->_data, $pos++, 1);
|
||||
$this->_pictureType = ord($this->_data{$pos++});
|
||||
$this->_data = substr($this->_data, $pos);
|
||||
|
||||
switch ($this->_encoding) {
|
||||
case self::UTF16:
|
||||
list ($this->_description, $this->_data) =
|
||||
preg_split("/\\x00\\x00/", substr($this->_data, $pos), 2);
|
||||
$this->_description = Transform::getString16LE($this->_description);
|
||||
break;
|
||||
$bom = substr($this->_data, 0, 2);
|
||||
$this->_data = substr($this->_data, 2);
|
||||
if ($bom == 0xfffe) {
|
||||
list ($this->_description, $this->_data) =
|
||||
preg_split("/\\x00\\x00/", $this->_data, 2);
|
||||
$this->_description = Transform::getString16LE($this->_description);
|
||||
break;
|
||||
}
|
||||
case self::UTF16BE:
|
||||
list ($this->_description, $this->_data) =
|
||||
preg_split("/\\x00\\x00/", substr($this->_data, $pos), 2);
|
||||
preg_split("/\\x00\\x00/", $this->_data, 2);
|
||||
$this->_description = Transform::getString16BE($this->_description);
|
||||
break;
|
||||
default:
|
||||
list ($this->_description, $this->_data) =
|
||||
preg_split("/\\x00/", substr($this->_data, $pos), 2);
|
||||
$this->_description = Transform::getString8($this->_description);
|
||||
preg_split("/\\x00/", $this->_data, 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,19 +66,23 @@ abstract class ID3_Frame_AbstractText extends ID3_Frame
|
||||
{
|
||||
parent::__construct($reader);
|
||||
|
||||
$this->_encoding = substr($this->_data, 0, 1);
|
||||
$this->_encoding = ord($this->_data{0});
|
||||
$this->_data = substr($this->_data, 1);
|
||||
switch ($this->_encoding) {
|
||||
case self::UTF16:
|
||||
$this->_data = Transform::getString16LE(substr($this->_data, 1));
|
||||
$this->_text = preg_split("/\\x00\\x00/", $this->_data);
|
||||
break;
|
||||
$bom = substr($this->_data, 0, 2);
|
||||
$this->_data = substr($this->_data, 2);
|
||||
if ($bom == 0xfffe) {
|
||||
$this->_text =
|
||||
preg_split("/\\x00\\x00/", Transform::getString16LE($this->_data));
|
||||
break;
|
||||
}
|
||||
case self::UTF16BE:
|
||||
$this->_data = Transform::getString16BE(substr($this->_data, 1));
|
||||
$this->_text = preg_split("/\\x00\\x00/", $this->_data);
|
||||
$this->_text =
|
||||
preg_split("/\\x00\\x00/", Transform::getString16BE($this->_data));
|
||||
break;
|
||||
default:
|
||||
$this->_data = Transform::getString8(substr($this->_data, 1));
|
||||
$this->_text = preg_split("/\\x00/", $this->_data);
|
||||
$this->_text = preg_split("/\\x00/", Transform::getString8($this->_data));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,25 +78,30 @@ final class ID3_Frame_COMM extends ID3_Frame
|
||||
{
|
||||
parent::__construct($reader);
|
||||
|
||||
$this->_encoding = substr($this->_data, 0, 1);
|
||||
$this->_encoding = ord($this->_data{0});
|
||||
$this->_language = substr($this->_data, 1, 3);
|
||||
$this->_data = substr($this->_data, 4);
|
||||
|
||||
switch ($this->_encoding) {
|
||||
case self::UTF16:
|
||||
list ($this->_description, $this->_text) =
|
||||
preg_split("/\\x00\\x00/", substr($this->_data, 4), 2);
|
||||
$this->_description = Transform::getString16LE($this->_description);
|
||||
$this->_text = Transform::getString16LE($this->_text);
|
||||
break;
|
||||
$bom = substr($this->_data, 0, 2);
|
||||
$this->_data = substr($this->_data, 2);
|
||||
if ($bom == 0xfffe) {
|
||||
list ($this->_description, $this->_text) =
|
||||
preg_split("/\\x00\\x00/", $this->_data, 2);
|
||||
$this->_description = Transform::getString16LE($this->_description);
|
||||
$this->_text = Transform::getString16LE($this->_text);
|
||||
break;
|
||||
}
|
||||
case self::UTF16BE:
|
||||
list ($this->_description, $this->_text) =
|
||||
preg_split("/\\x00\\x00/", substr($this->_data, 4), 2);
|
||||
preg_split("/\\x00\\x00/", $this->_data, 2);
|
||||
$this->_description = Transform::getString16BE($this->_description);
|
||||
$this->_text = Transform::getString16BE($this->_text);
|
||||
break;
|
||||
default:
|
||||
list ($this->_description, $this->_text) =
|
||||
preg_split("/\\x00/", substr($this->_data, 4), 2);
|
||||
preg_split("/\\x00/", $this->_data, 2);
|
||||
$this->_description = Transform::getString8($this->_description);
|
||||
$this->_text = Transform::getString8($this->_text);
|
||||
}
|
||||
|
||||
@@ -63,15 +63,10 @@ final class ID3_Frame_COMR extends ID3_Frame
|
||||
* @var Array
|
||||
*/
|
||||
public static $types = array
|
||||
(0x00 => "Other",
|
||||
0x01 => "Standard CD album with other songs",
|
||||
0x02 => "Compressed audio on CD",
|
||||
0x03 => "File over the Internet",
|
||||
0x04 => "Stream over the Internet",
|
||||
0x05 => "As note sheets",
|
||||
0x06 => "As note sheets in a book with other sheets",
|
||||
0x07 => "Music on other media",
|
||||
0x08 => "Non-musical merchandise");
|
||||
("Other", "Standard CD album with other songs", "Compressed audio on CD",
|
||||
"File over the Internet", "Stream over the Internet", "As note sheets",
|
||||
"As note sheets in a book with other sheets", "Music on other media",
|
||||
"Non-musical merchandise");
|
||||
|
||||
/** @var integer */
|
||||
private $_encoding;
|
||||
@@ -109,7 +104,7 @@ final class ID3_Frame_COMR extends ID3_Frame
|
||||
{
|
||||
parent::__construct($reader);
|
||||
|
||||
$this->_encoding = substr($this->_data, 0, 1);
|
||||
$this->_encoding = ord($this->_data{0});
|
||||
list($pricing, $this->_data) =
|
||||
preg_split("/\\x00/", substr($this->_data, 1), 2);
|
||||
$this->_currency = substr($pricing, 0, 3);
|
||||
@@ -117,24 +112,29 @@ final class ID3_Frame_COMR extends ID3_Frame
|
||||
$this->_date = substr($this->_data, 0, 8);
|
||||
list($this->_contact, $this->_data) =
|
||||
preg_split("/\\x00/", substr($this->_data, 8), 2);
|
||||
$this->_delivery = substr($this->_data, 0, 1);
|
||||
$this->_delivery = ord($this->_data{0});
|
||||
$this->_data = substr($this->_data, 1);
|
||||
|
||||
switch ($this->_encoding) {
|
||||
case self::UTF16:
|
||||
list ($this->_seller, $this->_description, $this->_data) =
|
||||
preg_split("/\\x00\\x00/", substr($this->_data, 1), 3);
|
||||
$this->_seller = Transform::getString16LE($this->_seller);
|
||||
$this->_description = Transform::getString16LE($this->_description);
|
||||
break;
|
||||
$bom = substr($this->_data, 0, 2);
|
||||
$this->_data = substr($this->_data, 2);
|
||||
if ($bom == 0xfffe) {
|
||||
list ($this->_seller, $this->_description, $this->_data) =
|
||||
preg_split("/\\x00\\x00/", $this->_data, 3);
|
||||
$this->_seller = Transform::getString16LE($this->_seller);
|
||||
$this->_description = Transform::getString16LE($this->_description);
|
||||
break;
|
||||
}
|
||||
case self::UTF16BE:
|
||||
list ($this->_seller, $this->_description, $this->_data) =
|
||||
preg_split("/\\x00\\x00/", substr($this->_data, 1), 3);
|
||||
preg_split("/\\x00\\x00/", $this->_data, 3);
|
||||
$this->_seller = Transform::getString16BE($this->_seller);
|
||||
$this->_description = Transform::getString16BE($this->_description);
|
||||
break;
|
||||
default:
|
||||
list ($this->_seller, $this->_description, $this->_data) =
|
||||
preg_split("/\\x00/", substr($this->_data, 1), 3);
|
||||
preg_split("/\\x00/", $this->_data, 3);
|
||||
$this->_seller = Transform::getString8($this->_seller);
|
||||
$this->_description = Transform::getString8($this->_description);
|
||||
}
|
||||
|
||||
@@ -68,46 +68,19 @@ final class ID3_Frame_ETCO extends ID3_Frame
|
||||
* @var Array
|
||||
*/
|
||||
public static $types = array
|
||||
(0x00 => "Padding",
|
||||
0x01 => "End of initial silence",
|
||||
0x02 => "Intro start",
|
||||
0x03 => "Main part start",
|
||||
0x04 => "Outro start",
|
||||
0x05 => "Outro end",
|
||||
0x06 => "Verse start",
|
||||
0x07 => "Refrain start",
|
||||
0x08 => "Interlude start",
|
||||
0x09 => "Theme start",
|
||||
0x0a => "Variation start",
|
||||
0x0b => "Key change",
|
||||
0x0c => "Time change",
|
||||
0x0d => "Momentary unwanted noise",
|
||||
0x0e => "Sustained noise",
|
||||
0x0f => "Sustained noise end",
|
||||
0x10 => "Intro end",
|
||||
0x11 => "Main part end",
|
||||
0x12 => "Verse end",
|
||||
0x13 => "Refrain end",
|
||||
0x14 => "Theme end",
|
||||
0x15 => "Profanity",
|
||||
0x16 => "Profanity end",
|
||||
0xe0 => "User event",
|
||||
0xe1 => "User event",
|
||||
0xe2 => "User event",
|
||||
0xe3 => "User event",
|
||||
0xe4 => "User event",
|
||||
0xe5 => "User event",
|
||||
0xe6 => "User event",
|
||||
0xe7 => "User event",
|
||||
0xea => "User event",
|
||||
0xeb => "User event",
|
||||
0xec => "User event",
|
||||
0xed => "User event",
|
||||
0xee => "User event",
|
||||
0xef => "User event",
|
||||
0xfd => "Audio end (start of silence)",
|
||||
0xfe => "Audio file ends",
|
||||
0xff => "One more byte of events follows");
|
||||
("Padding", "End of initial silence", "Intro start", "Main part start",
|
||||
"Outro start", "Outro end", "Verse start","Refrain start",
|
||||
"Interlude start", "Theme start", "Variation start", "Key change",
|
||||
"Time change", "Momentary unwanted noise", "Sustained noise",
|
||||
"Sustained noise end", "Intro end", "Main part end", "Verse end",
|
||||
"Refrain end", "Theme end", "Profanity", "Profanity end",
|
||||
|
||||
0xe0 => "User event", "User event", "User event", "User event",
|
||||
"User event", "User event", "User event", "User event", "User event",
|
||||
"User event", "User event", "User event", "User event", "User event",
|
||||
|
||||
0xfd => "Audio end (start of silence)", "Audio file ends",
|
||||
"One more byte of events follows");
|
||||
|
||||
/** @var integer */
|
||||
private $_format;
|
||||
@@ -124,11 +97,11 @@ final class ID3_Frame_ETCO extends ID3_Frame
|
||||
{
|
||||
parent::__construct($reader);
|
||||
|
||||
$this->_format = substr($this->_data, 0, 1);
|
||||
$this->_format = ord($this->_data{0});
|
||||
|
||||
for ($i = 1; $i < $this->getSize(); $i += 5) {
|
||||
$this->_events[Transform::getInt32BE(substr($this->_data, $i + 1, 4))] =
|
||||
$data = substr($this->_data, $i, 1);
|
||||
$data = $this->_data{$i};
|
||||
if ($data == 0xff)
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -73,25 +73,31 @@ final class ID3_Frame_GEOB extends ID3_Frame
|
||||
{
|
||||
parent::__construct($reader);
|
||||
|
||||
$this->_encoding = substr($this->_data, 0, 1);
|
||||
$this->_encoding = ord($this->_data{0});
|
||||
$this->_mimeType = substr
|
||||
($this->_data, 1, ($pos = strpos($this->_data, "\0", 1)) - 1);
|
||||
$this->_data = substr($this->_data, $pos);
|
||||
|
||||
switch ($this->_encoding) {
|
||||
case self::UTF16:
|
||||
list ($this->_filename, $this->_description, $this->_data) =
|
||||
preg_split("/\\x00\\x00/", substr($this->_data, $pos), 3);
|
||||
$this->_filename = Transform::getString16LE($this->_filename);
|
||||
$this->_description = Transform::getString16LE($this->_description);
|
||||
break;
|
||||
$bom = substr($this->_data, 0, 2);
|
||||
$this->_data = substr($this->_data, 2);
|
||||
if ($bom == 0xfffe) {
|
||||
list ($this->_filename, $this->_description, $this->_data) =
|
||||
preg_split("/\\x00\\x00/", $this->_data, 3);
|
||||
$this->_filename = Transform::getString16LE($this->_filename);
|
||||
$this->_description = Transform::getString16LE($this->_description);
|
||||
break;
|
||||
}
|
||||
case self::UTF16BE:
|
||||
list ($this->_filename, $this->_description, $this->_data) =
|
||||
preg_split("/\\x00\\x00/", substr($this->_data, $pos), 3);
|
||||
preg_split("/\\x00\\x00/", $this->_data, 3);
|
||||
$this->_filename = Transform::getString16BE($this->_filename);
|
||||
$this->_description = Transform::getString16BE($this->_description);
|
||||
break;
|
||||
default:
|
||||
list ($this->_filename, $this->_description, $this->_data) =
|
||||
preg_split("/\\x00/", substr($this->_data, $pos), 3);
|
||||
preg_split("/\\x00/", $this->_data, 3);
|
||||
$this->_filename = Transform::getString8($this->_filename);
|
||||
$this->_description = Transform::getString8($this->_description);
|
||||
}
|
||||
|
||||
@@ -35,9 +35,6 @@
|
||||
|
||||
/**#@+ @ignore */
|
||||
require_once("ID3/Frame.php");
|
||||
require_once("ID3/Encoding.php");
|
||||
require_once("ID3/Language.php");
|
||||
require_once("ID3/Timing.php");
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -79,21 +79,26 @@ final class ID3_Frame_OWNE extends ID3_Frame
|
||||
{
|
||||
parent::__construct($reader);
|
||||
|
||||
$this->_encoding = substr($this->_data, 0, 1);
|
||||
list($tmp1, $tmp2) = preg_split("/\\x00/", substr($this->_data, 1), 2);
|
||||
$this->_currency = substr($tmp1, 0, 3);
|
||||
$this->_price = substr($tmp1, 3);
|
||||
$this->_date = substr($tmp2, 0, 8);
|
||||
$this->_encoding = ord($this->_data{0});
|
||||
list($tmp, $this->_data) = preg_split("/\\x00/", substr($this->_data, 1), 2);
|
||||
$this->_currency = substr($tmp, 0, 3);
|
||||
$this->_price = substr($tmp, 3);
|
||||
$this->_date = substr($this->_data, 0, 8);
|
||||
$this->_data = substr($this->_data, 8);
|
||||
|
||||
switch ($this->_encoding) {
|
||||
case self::UTF16:
|
||||
$this->_seller = Transform::getString16LE(substr($tmp2, 8));
|
||||
break;
|
||||
$bom = substr($this->_data, 0, 2);
|
||||
$this->_data = substr($this->_data, 2);
|
||||
if ($bom == 0xfffe) {
|
||||
$this->_seller = Transform::getString16LE($this->_data);
|
||||
break;
|
||||
}
|
||||
case self::UTF16BE:
|
||||
$this->_seller = Transform::getString16BE(substr($tmp2, 8));
|
||||
$this->_seller = Transform::getString16BE($this->_data);
|
||||
break;
|
||||
default:
|
||||
$this->_seller = Transform::getString8(substr($tmp2, 8));
|
||||
$this->_seller = Transform::getString8($this->_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ final class ID3_Frame_POSS extends ID3_Frame
|
||||
{
|
||||
parent::__construct($reader);
|
||||
|
||||
$this->_format = substr($this->_data, 0, 1);
|
||||
$this->_format = ord($this->_data{0});
|
||||
$this->_position = Transform::getInt32BE(substr($this->_data, 1, 4));
|
||||
}
|
||||
|
||||
|
||||
@@ -65,15 +65,8 @@ final class ID3_Frame_USER extends ID3_Frame
|
||||
* @var Array
|
||||
*/
|
||||
public static $types = array
|
||||
(0x00 => "Other",
|
||||
0x01 => "Lyrics",
|
||||
0x02 => "Text transcription",
|
||||
0x03 => "Movement/Part name",
|
||||
0x04 => "Eevents",
|
||||
0x05 => "Chord",
|
||||
0x06 => "Trivia",
|
||||
0x07 => "URLs to webpages",
|
||||
0x08 => "URLs to images");
|
||||
("Other", "Lyrics", "Text transcription", "Movement/Part name", "Eevents",
|
||||
"Chord", "Trivia", "URLs to webpages", "URLs to images");
|
||||
|
||||
/** @var integer */
|
||||
private $_encoding;
|
||||
@@ -102,25 +95,30 @@ final class ID3_Frame_USER extends ID3_Frame
|
||||
{
|
||||
parent::__construct($reader);
|
||||
|
||||
$this->_encoding = substr($this->_data, 0, 1);
|
||||
$this->_encoding = ord($this->_data{0});
|
||||
$this->_language = substr($this->_data, 1, 3);
|
||||
$this->_format = substr($this->_data, 3, 1);
|
||||
$this->_type = substr($this->_data, 4, 1);
|
||||
$this->_format = ord($this->_data{3});
|
||||
$this->_type = ord($this->_data{4});
|
||||
$this->_data = substr($this->_data, 5);
|
||||
|
||||
switch ($this->_encoding) {
|
||||
case self::UTF16:
|
||||
list($this->_description, $this->_data) =
|
||||
preg_split("/\\x00\\x00/", substr($this->_data, 5), 2);
|
||||
$this->_description = Transform::getString16LE($this->_description);
|
||||
break;
|
||||
$bom = substr($this->_data, 0, 2);
|
||||
$this->_data = substr($this->_data, 2);
|
||||
if ($bom == 0xfffe) {
|
||||
list($this->_description, $this->_data) =
|
||||
preg_split("/\\x00\\x00/", $this->_data, 2);
|
||||
$this->_description = Transform::getString16LE($this->_description);
|
||||
break;
|
||||
}
|
||||
case self::UTF16BE:
|
||||
list($this->_description, $this->_data) =
|
||||
preg_split("/\\x00\\x00/", substr($this->_data, 5), 2);
|
||||
preg_split("/\\x00\\x00/", $this->_data, 2);
|
||||
$this->_description = Transform::getString16BE($this->_description);
|
||||
break;
|
||||
default:
|
||||
list($this->_description, $this->_data) =
|
||||
preg_split("/\\x00/", substr($this->_data, 5), 2);
|
||||
preg_split("/\\x00/", $this->_data, 2);
|
||||
$this->_description = Transform::getString8($this->_description);
|
||||
}
|
||||
|
||||
|
||||
@@ -78,8 +78,7 @@ final class ID3_Frame_SYTC extends ID3_Frame
|
||||
{
|
||||
parent::__construct($reader);
|
||||
|
||||
$this->_format = substr($this->_data, 0, 1);
|
||||
|
||||
$this->_format = ord($this->_data{0});
|
||||
$this->_data = substr($this->_data, 1); // FIXME: Better parsing of data
|
||||
}
|
||||
|
||||
|
||||
@@ -74,18 +74,23 @@ final class ID3_Frame_USER extends ID3_Frame
|
||||
{
|
||||
parent::__construct($reader);
|
||||
|
||||
$this->_encoding = substr($this->_data, 0, 1);
|
||||
$this->_encoding = ord($this->_data{0});
|
||||
$this->_language = substr($this->_data, 1, 3);
|
||||
|
||||
$this->_data = substr($this->_data, 4);
|
||||
|
||||
switch ($this->_encoding) {
|
||||
case self::UTF16:
|
||||
$this->_text = Transform::getString16LE(substr($this->_data, 4));
|
||||
break;
|
||||
$bom = substr($this->_data, 0, 2);
|
||||
$this->_data = substr($this->_data, 2);
|
||||
if ($bom == 0xfffe) {
|
||||
$this->_text = Transform::getString16LE($this->_data);
|
||||
break;
|
||||
}
|
||||
case self::UTF16BE:
|
||||
$this->_text = Transform::getString16BE(substr($this->_data, 4));
|
||||
$this->_text = Transform::getString16BE($this->_data);
|
||||
break;
|
||||
default:
|
||||
$this->_text = Transform::getString8(substr($this->_data, 4));
|
||||
$this->_text = Transform::getString8($this->_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,25 +76,30 @@ final class ID3_Frame_USLT extends ID3_Frame
|
||||
{
|
||||
parent::__construct($reader);
|
||||
|
||||
$this->_encoding = substr($this->_data, 0, 1);
|
||||
$this->_encoding = ord($this->_data{0});
|
||||
$this->_language = substr($this->_data, 1, 3);
|
||||
$this->_data = substr($this->_data, 4);
|
||||
|
||||
switch ($this->_encoding) {
|
||||
case self::UTF16:
|
||||
list ($this->_description, $this->_text) =
|
||||
preg_split("/\\x00\\x00/", substr($this->_data, 4), 2);
|
||||
$this->_description = Transform::getString16LE($this->_description);
|
||||
$this->_text = Transform::getString16LE($this->_text);
|
||||
break;
|
||||
$bom = substr($this->_data, 0, 2);
|
||||
$this->_data = substr($this->_data, 2);
|
||||
if ($bom == 0xfffe) {
|
||||
list ($this->_description, $this->_text) =
|
||||
preg_split("/\\x00\\x00/", $this->_data, 2);
|
||||
$this->_description = Transform::getString16LE($this->_description);
|
||||
$this->_text = Transform::getString16LE($this->_text);
|
||||
break;
|
||||
}
|
||||
case self::UTF16BE:
|
||||
list ($this->_description, $this->_text) =
|
||||
preg_split("/\\x00\\x00/", substr($this->_data, 4), 2);
|
||||
preg_split("/\\x00\\x00/", $this->_data, 2);
|
||||
$this->_description = Transform::getString16BE($this->_description);
|
||||
$this->_text = Transform::getString16BE($this->_text);
|
||||
break;
|
||||
default:
|
||||
list ($this->_description, $this->_text) =
|
||||
preg_split("/\\x00/", substr($this->_data, 4), 2);
|
||||
preg_split("/\\x00/", $this->_data, 2);
|
||||
$this->_description = Transform::getString8($this->_description);
|
||||
$this->_text = Transform::getString8($this->_text);
|
||||
}
|
||||
|
||||
@@ -70,23 +70,29 @@ final class ID3_Frame_WXXX extends ID3_Frame_AbstractLink
|
||||
{
|
||||
parent::__construct($reader);
|
||||
|
||||
$this->_encoding = substr($this->_data, 0, 1);
|
||||
$this->_encoding = ord($this->_data{0});
|
||||
$this->_data = substr($this->_data, 1);
|
||||
|
||||
switch ($this->_encoding) {
|
||||
case self::UTF16:
|
||||
$chunks = preg_split("/\\x00\\x00/", substr($this->_data, 1));
|
||||
$this->_description = Transform::getString16LE($chunks[0]);
|
||||
$this->_link = $chunks[1];
|
||||
break;
|
||||
$bom = substr($this->_data, 0, 2);
|
||||
$this->_data = substr($this->_data, 2);
|
||||
if ($bom == 0xfffe) {
|
||||
list($this->_description, $this->_link) =
|
||||
preg_split("/\\x00\\x00/", $this->_data, 2);
|
||||
$this->_description = Transform::getString16LE($this->_description);
|
||||
break;
|
||||
}
|
||||
case self::UTF16BE:
|
||||
$chunks = preg_split("/\\x00\\x00/", substr($this->_data, 1));
|
||||
$this->_description = Transform::getString16BE($chunks[0]);
|
||||
$this->_link = $chunks[1];
|
||||
list($this->_description, $this->_link) =
|
||||
preg_split("/\\x00\\x00/", $this->_data, 2);
|
||||
$this->_description = Transform::getString16BE($this->_description);
|
||||
break;
|
||||
case self::UTF8:
|
||||
case self::ISO88591:
|
||||
default:
|
||||
list($this->_description, $this->_link) =
|
||||
preg_split("/\\x00/", substr($this->_data, 1));
|
||||
preg_split("/\\x00/", $this->_data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,10 +50,10 @@
|
||||
interface ID3_Timing
|
||||
{
|
||||
/** The timestamp is an absolute time, using MPEG frames as unit. */
|
||||
const MPEG_FRAMES = 0x01;
|
||||
const MPEG_FRAMES = 1;
|
||||
|
||||
/** The timestamp is an absolute time, using milliseconds as unit. */
|
||||
const MILLISECONDS = 0x02;
|
||||
const MILLISECONDS = 2;
|
||||
|
||||
/**
|
||||
* Returns the timing format.
|
||||
|
||||
Reference in New Issue
Block a user