如何从Laravel的存储中播放视频

发布于 2025-02-12 12:03:10 字数 501 浏览 1 评论 0原文

我在存储文件夹中上传了一个视频文件,并将路径存储在数据库中。

我想在刀片上播放视频,但它不工作

video.blade.php

<video controls>
   <source src="{{asset('storage/'. \App\Video::where('vid_id', $vid_id)->value('vid_path'))}}" type="video/mp4">
   <source src="movie.ogg" type="video/ogg">
   Your browser does not support the video tag.
</video>

通往视频的路径,

http://127.0.0.1:8000/storage/videos/2022_06_19_HmhR5cXugaEfvWe315Vi.mp4

文件成功上传但不播放

I uploaded a video file in the storage folder and stored the path in database.

I want to play the video on the blade but it is not working

video.blade.php

<video controls>
   <source src="{{asset('storage/'. \App\Video::where('vid_id', $vid_id)->value('vid_path'))}}" type="video/mp4">
   <source src="movie.ogg" type="video/ogg">
   Your browser does not support the video tag.
</video>

Path to the video

http://127.0.0.1:8000/storage/videos/2022_06_19_HmhR5cXugaEfvWe315Vi.mp4

The file uploads successfully but it does not play

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

谁对谁错谁最难过 2025-02-19 12:03:10

您需要将公共路径用于视频资产。我建议的是:

  1. 检查您是否可以直接从您提到的URL访问视频。

  2. 在您的代码段中,删除
    &lt; source src =“ movie.ogg” type =“ video/ogg”&gt;,除非您有该格式的movie.ogg资源

  3. 使用url()或public_path()或public_path(),或资产()帮助者分配SRC
    这样的东西:

     &lt; video width =“ 320” height =“ 240”控件&gt;
         &lt; source src =“ {{asset('to to y-your-video')}}}” type =“ video/mp4”&gt;
     &lt;/video&gt;
     

You need to use the public path for the video asset. What I'd suggest:

  1. Check if you can access the video directly from the URL that you mentioned.

  2. In your code snippet, remove
    <source src="movie.ogg" type="video/ogg">unless you have a movie.ogg resource of that format

  3. Use url(), or public_path(), or asset() helpers to assign the src
    something like this:

     <video width="320" height="240" controls>
         <source src="{{asset('path-to-your-video')}}" type="video/mp4">
     </video>
    
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文