ストリーミングで問題が発生しました.mp4 PHPからHTML5ビデオタグへのビデオ。ビデオストリームはうまく動作し、前後に動く。しかし、私がメニュー内のリンクをクリックすると、サイトは変更されません。読み込みアイコンがタブに表示され、開発ツールに要求があることが示されます。しかし、要求はビデオストリーム終了まで「待機」する。したがって、ビデオが終了した場合、新しいPageがロードされますが、前はロードされません。PHPストリームからhtml5ビデオ、ページナビゲーションが機能しない
これに関するご意見はありますか?
PS:session_write_close()を追加しています。ファイルをストリーミングする前に問題を解決します。しかし、それは、PHPコード
<video style="width:100%;" preload="metadata" controls="">
<source src="/uploads/getfile?image_path=5%2FOKzAAFlSub-VLsnFWvkPWXBLluwOV-Q5DIuqJkPpDubahlAosK.mp4&type=20" type="video/mp4">
Your browser does not support the video tag.
</video>
...私にとっては少しもハックになりますsession_write_close()を追加
$file = Yii::getAlias('@app') . '/../files/uploads/' .$image_path;
$fp = @fopen($file, 'rb');
$size = filesize($file); // File size
$length = $size; // Content length
$start = 0; // Start byte
$end = $size - 1; // End byte
header('Content-type: video/mp4');
header("Accept-Ranges: 0-$length");
header("Accept-Ranges: bytes");
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);
ob_flush();
}
fclose($fp);
exit();
ありがとうございます。 コンテンツは、すべてのユーザーではなく一部のユーザーのみが見ることができるコンテンツです。したがって、ファイルは非公開で保存されます。現時点では、私たちのシステムは少数の人にしか対応できません - それは何千人ものシステムではありません;) – Lugaru