问题描述
我正在使用下面的代码从S3和服务器上下载Laravel项目中的mp4文件,这些文件可以很好地下载,但在播放时总是会出错,因为文件类型不受支持。
方法1:
$s3 = \CommonHelper::getS3ClientObj();
$file = $s3->getObjectUrl('video-testimonials',"96066883.mp4",'+5 minutes',['ResponseContentDisposition' => 'attachment; filename="96066883.mp4"']);
$filename = '96066883.mp4';
header('Content-Description: File Transfer');
header("Content-type: video/$type"); # Without this and line below didn't worked
header('Content-Disposition: attachment; filename='.$filename);
header('Content-Transfer-Encoding: binary');
header('Cache-Control: must-revalidate');
header('Pragma: public');
ob_clean();
flush();
readfile($file);
exit;
方法2:
$file= "/var/www/html/videos/$vid.$type";
$headers = array(
"Content-Type: video/$type",);
return Response::download($file,"video-$vid.$type",$headers);
这两种方法都可以下载文件,但是它永远无法播放。文件名和路径正确。我现在还能尝试什么解决方法?
在媒体播放器中播放视频时出错:https://www.screencast.com/t/MnXVIrZh
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)