These are my mods - at the top,
Code: Select all
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use phpbb\symfony_request;
Then:
Code: Select all
if (!@file_exists($filename))
{
send_status_line(404, 'Not Found');
trigger_error('ERROR_NO_ATTACHMENT');
}
// *** Adding HTML5 audio/video content! Caveat Emptor
if (($category == ATTACHMENT_CATEGORY_HTML5)
&& ((strpos($attachment['mimetype'], 'video') !== 0)||(strpos($attachment['mimetype'], 'audio') !== 0)))
{
$response = new BinaryFileResponse($filename);
$response->headers->set('Content-Type', 'video/mp4');
global $request;
$response->prepare($request);
$response->send();
exit;
}
// Correct the mime type - we force application/octetstream for all files, except images
// Please do not change this, it is a security precaution
if (($category != ATTACHMENT_CATEGORY_IMAGE || strpos($attachment['mimetype'], 'image') !== 0))
...
I've forced the Content-Type here to be video, but of course if I get it to work I would set it to audio/video as appropriate.