如何在前端将 Laravel Voyager 中存储的视频作为文件显示?

问题描述 投票:0回答:2

我想在前端显示 Laravel Voyager 存储的多个视频, 我正在尝试使用以下命令提取通过管理员上传的视频:

@foreach ($videos as $video)
    <video width="320" height="240" controls>
        <source src="{{ Voyager::image( $video->file) }}" type="video/mp4">
    </video>
@endforeach

但是不行,有人可以帮忙吗?

laravel video display voyager
2个回答
0
投票

您可以像这样直接从存储中调用它:

@foreach ($videos as $video)
   <video width="320" height="240" controls>
        <source src="{{ Storage::url($video->file) }}" type="video/mp4">
       // Or 
   <source src="{{ asset("storage/$video->file") }}" type="video/mp4">
      </video>
@endforeach

0
投票

@php // 解码 JSON 字段 $fileInfo = json_decode($model->file_column, true); @endphp

@if ($fileInfo && isset($fileInfo[0]['download_link'])) 您的浏览器不支持视频标签。 @endif

© www.soinside.com 2019 - 2024. All rights reserved.