public function readAllTags() { assert($this->validMp3 === TRUE); $bytesPos = 10; //From headers $this->fileReader->setMap(array("frameId" => array(BinaryFileReader::FIXED, 4), "size" => array(BinaryFileReader::FIXED, 4, BinaryFileReader::INT), "flag" => array(BinaryFileReader::FIXED, 2), "body" => array(BinaryFileReader::SIZE_OF, "size"))); $id3Tags = Id3Tags::getId3Tags(); while ($file_data = $this->fileReader->read()) { if (!in_array($file_data->frameId, array_keys($id3Tags))) { break; } $body = $file_data->body; // If frame is a text frame then we have to consider // encoding as shown in spec section 4.2 if ($file_data->frameId[0] === "T") { // First character determines the encoding, 1 = ISO-8859-1, 0 = UTF - 16 if (intval(bin2hex($body[0]), 16) === 1) { $body = mb_convert_encoding(substr($body, 1), 'UTF-8', 'UTF-16'); } // Convert UTF-16 to UTF-8 to compatible with current browsers } $this->id3Array[$file_data->frameId] = array("fullTagName" => $id3Tags[$file_data->frameId], "position" => $bytesPos, "size" => $file_data->size, "body" => $body); $bytesPos += 4 + 4 + 2 + $file_data->size; } return $this; }
public function readAllTags() { assert($this->validMp3 === TRUE); $bytesPos = 10; //From headers $this->fileReader->setMap(array("frameId" => array(BinaryFileReader::FIXED, 4), "size" => array(BinaryFileReader::FIXED, 4, BinaryFileReader::INT), "flag" => array(BinaryFileReader::FIXED, 2), "body" => array(BinaryFileReader::SIZE_OF, "size"))); $id3Tags = Id3Tags::getId3Tags(); while ($file_data = $this->fileReader->read()) { if (!in_array($file_data->frameId, array_keys($id3Tags))) { break; } $this->id3Array[$file_data->frameId] = array("fullTagName" => $id3Tags[$file_data->frameId], "position" => $bytesPos, "size" => $file_data->size, "body" => $file_data->body); $bytesPos += 4 + 4 + 2 + $file_data->size; } return $this; }
/** * ReadAllTags is an indirection to readTags using full tags list * * @return Id3TagsReader */ public function readAllTags() { return $this->readTags(Id3Tags::getId3Tags()); }