path = $path; $this->init('', 200); $mime = ['mp3' => 'audio/mpeg', 'm4a' => 'audio/mp4', 'wav' => 'audio/wav', 'amr' => 'audio/amr'][$extension]; $this->header([ 'Content-Type' => $mime, 'Content-Length' => (string) filesize($path), 'Content-Disposition' => 'inline; filename="recording.' . $extension . '"', 'Cache-Control' => 'private, no-store, max-age=0', 'Pragma' => 'no-cache', 'X-Content-Type-Options' => 'nosniff', 'Accept-Ranges' => 'none', ]); } protected function sendData(string $data): void { $stream = fopen($this->path, 'rb'); if ($stream === false) { return; } try { while (!feof($stream) && !connection_aborted()) { echo fread($stream, 1048576); } } finally { fclose($stream); } } }