Safari可以通过Laravel在Localhost上使用的开放视频

发布于 2025-01-19 04:21:36 字数 698 浏览 1 评论 0原文

这是我的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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

哎呦我呸! 2025-01-26 04:21:36

解决了。我正在使用命令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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文