cakephp 3响应文件和视频标签 [英] cakephp 3 response withFile and video tag
问题描述
我已经使用此代码通过CakePHP中的操作发送视频:
I've used this code to send a video using an action in CakePHP:
$response = $this->response->withFile(WWW_ROOT.'Component.webm',['download' => false]);
和模板内部:
<video class="img-responsive" controls>
<source src="<?= Router::url(['controller' => 'posts', 'action' => 'stream', $id]) ?>" />
</video>
Microsoft Edge中的一切都很好用。但是,当我在谷歌浏览器中查看页面并开始播放视频时,我无法访问我网站的任何其他页面,直到完全下载视频,30秒后,如果未下载视频,则会显示以下错误:
everything works great in Microsoft Edge. But when I view the page inside Google Chrome and I start playing the video I cannot visit any other page of my site, until the video is downloaded completely, and after 30 seconds, if the video is not downloaded this error is shown:
Maximum execution time of 30 seconds exceeded
推荐答案
我在这里发现了问题:
https://gist.github.com/ranacseruet/9826293#gistcomment-2141349
I found the problem here: https://gist.github.com/ranacseruet/9826293#gistcomment-2141349
我用 session_write_close();
在我的操作之上,现在chrome也可以。
I used session_write_close();
on top of my action and now chrome works too.
这篇关于cakephp 3响应文件和视频标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!