From 6b036f9e8a67be4e81c17cdb298d73e3e9b5fdb7 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 14 Sep 2024 07:43:45 -0400 Subject: [PATCH] Use an actual flag insead of begin and end comparison for when to output partial content because the partial code start from 0 --- web/views/view_video.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/web/views/view_video.php b/web/views/view_video.php index 415469e25..6f649660f 100644 --- a/web/views/view_video.php +++ b/web/views/view_video.php @@ -69,6 +69,7 @@ $size = filesize($path); $begin = 0; $end = $size-1; $length = $size; +$partial = false; if ( isset($_SERVER['HTTP_RANGE']) ) { ZM\Debug('Using Range '.$_SERVER['HTTP_RANGE']); @@ -79,6 +80,7 @@ if ( isset($_SERVER['HTTP_RANGE']) ) { } $length = $end - $begin + 1; ZM\Debug("Using Range $begin $end size: $size, length: $length"); + $partial = true; } } # end if HTTP_RANGE @@ -86,12 +88,12 @@ header('Content-type: video/mp4'); header('Accept-Ranges: bytes'); header('Content-Length: '.$length); # This is so that Save Image As give a useful filename -if ( $Event ) { +if ($Event) { header('Content-Disposition: inline; filename="' . $Event->DefaultVideo() . '"'); } else { header('Content-Disposition: inline;'); } -if ( $begin > 0 || $end < $size-1 ) { +if ($partial) { header('HTTP/1.0 206 Partial Content'); header("Content-Range: bytes $begin-$end/$size"); header("Content-Transfer-Encoding: binary\n"); @@ -102,7 +104,7 @@ if ( $begin > 0 || $end < $size-1 ) { // Apparently without these we get a few extra bytes of output at the end... flush(); -fseek($fh, $begin, 0); +if ($begin) fseek($fh, $begin, 0); while ($length && (!feof($fh)) && (connection_status() == 0)) { $amount = min(1024*16, $length);