编辑拉拉维尔的视频显示



嗨,如果有人可以帮助我,我在这里遇到了问题。我正在将图像保存在存储和编辑(更新)视图(刀片)上,为此我这样做:

<img src="{{url('/')}}/images/questions/{{ $question->id }}/medium/{{ $question->question_image }}" class="answer-image-create" id="question_image_box">

它工作正常,因为图像保存得很好,就像存储文件夹中的图像一样,但是存储中的音频和视频保存了很多数字,文件看起来像这样,例如videofile.mp4 :

4944 3303 0000 0000 0000 fffb 9240 0000
0000 004b 0500 0000 0000 0960 a000 000b
2987 3c19 4880 0965 30e7 8329 1001 f19b
12cd dc1b 1006 8caf 8011 311b f804 9014
fed2 d805 814a 7db3 a165 04e9 07ff c2e6
0500 3204 4cc3 ffc9 c1c6 e813 eaff fcd0
66c8 b95c 8a11 434f fffc c8b9 271a b4d5
ffff f97d 2412 4190 4cdd 93ff ffff fd33
4410 2fa6 91c0 08fc 66c4 b377 06c4 01a3
2be0 044c 46fe 0124 053f b4b6 0160 529f
6ce8 5941 3a41 fff0 b981 400c 8113 30ff
f270 71ba 04fa bfff 3419 b22e 5722 8450..

我尝试了这样的东西来显示视频,但它不起作用:

 <video width="320" height="240" preload="none" controls>
  <source src="{{url('/')}}/video/questions/{{ $question->id }}/original/{{ $question->question_video }}"  type="video/mp4">

任何想法..? 谢谢。

通过调整文件夹的结构来尝试这样的事情:

您从以下路线获取视频:

Route::get('/videos/questions/{id}/original/{quetion_video}', [ 'as' => 'video', 'uses' => 'VideoController@viewVideo' ]);

在控制器中:

function viewVideo($id, $quetion_video)
{
    $filename = storage_path() . "/videos/questions".$id."/original/".$quetion_video.".mp4";
    $headers = array(
        'Content-type' => 'video/mp4'
    );
    return Response::make( file_get_contents($filename), 200, $headers);
}

在您看来:

<video width="320" height="240" controls>
        <source src="{{ route('getVideo', [ 'id => '$question->id, 'question_video' => $question->question_video ])  }}" type="video/mp4">
</video>

这是你必须做什么的想法,你可以在这里获得示例和解释:

https://laracasts.com/discuss/channels/requests/how-to-let-user-play-audio-and-video-files-stored-in-directory-above-public

https://laracasts.com/discuss/channels/laravel/getting-video-from-storage-directory?page=0

https://laravel.io/forum/02-14-2016-how-read-uploaded-video-files-from-storage-directory

最新更新