Safari可以通过Laravel在Localhost上使用的开放视频
这是我的HTML:
<video id="background-video" autoplay loop muted poster="">
<source src="{{ asset('media/video/video.mp4') }}" type="video/mp4">
</video>
访问网站时的视频应自动播放,并且可以在Chrome和Firefox中完美运行。但不是野生动物园。此问题仅在通过Localhost访问视频时发生。从我的磁盘上直接打开视频作为普通文件,可以很好地播放。
这使我认为这个问题发生在Laravel的某个地方,未能通过Localhost为Safari服务。
这是一个已知的问题,如果是这样,如何解决它?我正在使用Laravel V9。
编辑:
因此,在Safari中:
- http:// localhost:8000/path/to/video.mp4-&gt; FAILS
&lt; source src =“ {{Asset('/path/to/video.mp4')}}}” type =“ video/mp4”&gt; gt;
(code) - &gt;失败- 文件://mysites/path/to/video.mp4-&gt;作品
This is my HTML:
<video id="background-video" autoplay loop muted poster="">
<source src="{{ asset('media/video/video.mp4') }}" type="video/mp4">
</video>
The video should autoplay when visiting the website, and it works perfectly in Chrome and Firefox. But not Safari. This problem only occurs when visiting the video through localhost. Opening the video as a normal file in Safari, straight from my disk, plays it fine.
This makes me think this problem occurs somewhere in Laravel failing to serve the MP4 for Safari through localhost.
Is this a known issue, and if so, how to solve it? I am using Laravel v9.
Edit:
So, in Safari:
- http://localhost:8000/path/to/video.mp4 -> fails
<source src="{{ asset('/path/to/video.mp4') }}" type="video/mp4">
(code) -> fails- file://mysites/path/to/video.mp4 -> works
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决了。我正在使用命令
php工匠服务
测试我的网站。这将打开PHP/Laravel开发服务器。但是该服务器配置不佳,无法处理“范围字节” Safari所需的流式传输MP4。只需将您的Laravel项目放在本地Apache服务器上并通过那里进行测试。
Solved it. I was using the command
php artisan serve
to test my website. This opens a PHP/Laravel development server. But this server is poorly configured and cannot handle the 'Range Bytes' Safari requires to stream MP4.Just place your Laravel project on a local Apache server and test it through there.