What are some best practices for implementing file streaming with PHP to ensure smooth playback?

When implementing file streaming with PHP, it is important to ensure smooth playback by properly setting the appropriate headers and using the correct streaming techniques. One best practice is to use the "readfile" function in PHP along with setting the "Content-Type" and "Content-Length" headers to properly stream the file to the client.

<?php
$file = 'path/to/your/file.mp4';

header('Content-Type: video/mp4');
header('Content-Length: ' . filesize($file));

readfile($file);
exit;
?>