php - 在Edit Laravel上观看视频

标签 php laravel audio video

嗨,我在这里遇到问题,如果有人可以帮助我。
我将图像保存在存储和编辑(更新) View ( Blade )上,原因是这样的:

<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' ]);

在您的 Controller 中:
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

关于php - 在Edit Laravel上观看视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46955115/

相关文章:

php - 拉维尔 5.4 : how to iterate through request array?

Android MP3 MediaPlayer 使某些手机崩溃

xcode - 如何检查 AVPlayer 是否有视频或只有音频?

php - 用 PHP 或 HTML 绘制图表

php - 使用 PHP 或 PHP-CLI 进行 OLE 自动化?

php - 用有意义的数据替换列值并在 mysql - php 中显示

php - 如何更改 tor ip 每个 curl_init()

php - 在 laravel 5.2 的分页链接中添加了随机字符

php - Laravel mySql 加入

swift - 如何为我的音频应用程序获得可靠的计时?