我正在尝试在我的Mac和手机上显示视频,但我无法让它工作。我的视频是由php提供的,我一直在阅读它与范围标题没有被发送有关但我无法弄清楚如何正确地做到这一点。 这是我到目前为止所拥有的:
HTML:
<video controls="true" autoplay muted loop>
<source src="http://my_site.com/video/394934" type="video/mp4">
</video>
PHP:
// Get file GUID
$file_guid = (int) get_input('file_guid', 0);
// Get file thumbnail size
$size = get_input('size', 'small');
$file = get_entity($file_guid);
if (!elgg_instanceof($file, 'object', 'file')) {
exit;
}
$simpletype = $file->simpletype;
if ($simpletype == "image") {
// Get file thumbnail
switch ($size) {
case "small":
$thumbfile = $file->thumbnail;
break;
case "medium":
$thumbfile = $file->smallthumb;
break;
case "large":
default:
$thumbfile = $file->largethumb;
break;
}
// Grab the file
if ($thumbfile && !empty($thumbfile)) {
$readfile = new ElggFile();
$readfile->owner_guid = $file->owner_guid;
$readfile->setFilename($thumbfile);
$mime = $file->getMimeType();
$contents = $readfile->grabFile();
// caching images for 10 days
header("Content-type: $mime");
header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', strtotime("+10 days")), true);
header("Pragma: public", true);
header("Cache-Control: public", true);
header("Content-Length: " . strlen($contents));
echo $contents;
exit;
}
}
答案 0 :(得分:2)
如果它实际上是一个范围标题问题,那么有一个github项目,其代码示例解决了Safari / Mac的这个问题: