function extract($start, $length) { $maxStrLen = strlen($this->str); $currentStrPos = $this->getStart(); $framesCount = 0; $time = 0; $startCount = -1; $endCount = -1; while ($currentStrPos < $maxStrLen) { if ($startCount == -1 && $time >= $start) { $startCount = $currentStrPos; } if ($endCount == -1 && $time >= $start + $length) { $endCount = $currentStrPos - $startCount; } $doFrame = true; $str = substr($this->str, $currentStrPos, 4); $strlen = strlen($str); $parts = array(); for ($i = 0; $i < $strlen; $i++) { $parts[] = $this->decbinFill(ord($str[$i]), 8); } if ($parts[0] != "11111111") { if ($maxStrLen - 128 > $currentStrPos) { $doFrame = false; } else { $doFrame = false; } } if ($doFrame) { $a = $this->doFrameStuff($parts); $currentStrPos += $a[0]; $time += $a[1]; $framesCount++; } else { break; } } $mp3 = new mp3(); if ($endCount == -1) { $endCount = $maxStrLen - $startCount; } if ($startCount != -1 && $endCount != -1) { $mp3->setStr(substr($this->str, $startCount, $endCount)); } return $mp3; }