mercredi 4 novembre 2015

video file is not working in laravel

I can't view video files from storage folder. My firebug shows ok response and below showing some error message. I think the problem is from <source src="'+response+'" type="video/webm">. I have attached firebug response success part and error part seperately. Could you please check and help me to load video.

JS

$( "#view-from-server" ).click(function(e){
    e.preventDefault();
    $.get("/profile/video", function(response){
        $( "#profile-video" ).html('<video width="400" height="240" controls id="profile-video"><source src="'+response+'" type="video/webm"></video>');
    });
});

route.php

Route::get('/profile/video', ['middleware' => 'auth', 'uses' => 'RecordingvideoController@index']);

RecordingvideoController.php

public function index()
    {
        $id                = Auth::user()->id;
        $details           = User::select('id', 'created_at')->find($id);
        $encrypt           = md5($details->id.$details->created_at);
        $directories       = Storage::files($encrypt);                                                  // Listout Files
        $webm              = preg_grep('/\/.*.webm$/', $directories);
        foreach($webm as $files){
            $split_folder_file = explode('/', $files);          //60e4dda43c442fe610bdbd4a0e5c3a12/4135209867745277.webm
            $splitted_file     = end($split_folder_file);       //4135209867745277.webm
            $file              = Storage::disk('local')->get($encrypt.'/'.$splitted_file);
            return response($file, 200)
                ->header('Content-Type', 'video/webm');
        }
    }

HTML

<div class="text-center">
   <button type="button" class="btn btn-sm  btn-rounded btn-default" id="view-from-server">View Profile Video</button>
            <br>
   <div id="profile-video"></div>
 </div>

enter image description here enter image description here



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire