From 9b9277660760d18f4d3dcce66077997a0992559a Mon Sep 17 00:00:00 2001
From: Markus Birth <markus@birth-online.de>
Date: Mon, 27 May 2024 23:45:35 +0100
Subject: [PATCH] Differentiate btw id3v1.0 and id3v1.1

---
 src/Mp3Info.php | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/Mp3Info.php b/src/Mp3Info.php
index bd9e650..57d27d7 100644
--- a/src/Mp3Info.php
+++ b/src/Mp3Info.php
@@ -444,9 +444,15 @@ class Mp3Info
         $this->tags1['artist'] = trim($this->fileObj->getBytes(30));
         $this->tags1['album'] = trim($this->fileObj->getBytes(30));
         $this->tags1['year'] = trim($this->fileObj->getBytes(4));
-        $this->tags1['comment'] = trim($this->fileObj->getBytes(28));
-        $this->fileObj->seekForward(1);
-        $this->tags1['track'] = ord($this->fileObj->getBytes(1));
+        $comment = $this->fileObj->getBytes(30);
+        if ($comment[28] == "\x00" && $comment[29] != "\x00") {
+            // id3v1.1 - last Byte of comment is trackNo
+            $this->tags1['track'] = ord($comment[29]);
+            $this->tags1['comment'] = trim(substr($comment, 0, 28));
+        } else {
+            // id3v1.0
+            $this->tags1['comment'] = trim($comment);
+        }
         $this->tags1['genre'] = ord($this->fileObj->getBytes(1));
         return 128;
     }