JLA wrote: |
Finally after putting it on the back burner - we've fixed attachment mod's ability to playback MP4 videos using videojs on Apple iPhone, iPad, iOS devices.
Example of this working now here
http://www.jlaforums.com/viewtopic.php?t=239387290
Turn out the trick is since the playback file is called by a separate php file - you have to send some headers in the response that were not being sent by the old way. Here is the specific code that deals with this for those who might have ran into the same problem
Code: |
$fp = fopen(**LOCATION OF YOUR FILE** . $physical_filename, "rb");
$size = **GIVE THE FILE SIZE HERE EITHER THROUGH PHP OR STORED IN DB/CACHE**;
$length = $size;
$start = 0;
$end = $size - 1;
header('Content-type: flv-application/octet-stream');
header("Accept-Ranges: 0-$length");
if (isset($_SERVER['HTTP_RANGE'])) {
$c_start = $start;
$c_end = $end;
list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2);
if (strpos($range, ',') !== false) {
header('HTTP/1.1 416 Requested Range Not Satisfiable');
header("Content-Range: bytes $start-$end/$size");
exit;
}
if ($range == '-') {
$c_start = $size - substr($range, 1);
} else {
$range = explode('-', $range);
$c_start = $range[0];
$c_end = (isset($range[1]) && is_numeric($range[1])) ? $range[1] : $size;
}
$c_end = ($c_end > $end) ? $end : $c_end;
if ($c_start > $c_end || $c_start > $size - 1 || $c_end >= $size) {
header('HTTP/1.1 416 Requested Range Not Satisfiable');
header("Content-Range: bytes $start-$end/$size");
exit;
}
$start = $c_start;
$end = $c_end;
$length = $end - $start + 1;
fseek($fp, $start);
header('HTTP/1.1 206 Partial Content');
}
header("Content-Range: bytes $start-$end/$size");
header("Content-Length: ".$length);
$buffer = 1024 * 8;
while(!feof($fp) && ($p = ftell($fp)) <= $end) {
if ($p + $buffer > $end) {
$buffer = $end - $p + 1;
}
set_time_limit(0);
echo fread($fp, $buffer);
flush();
}
fclose($fp);
exit;
|
Happy now |