-
-
Save MMTE/ee75455f33983593253ca80a0b13037b to your computer and use it in GitHub Desktop.
Laravel VideoStream.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
Route::get('/player', function () { | |
$video = "video/os_simpsons_s25e22_720p.mp4"; | |
$mime = "video/mp4"; | |
$title = "Os Simpsons"; | |
return view('player')->with(compact('video', 'mime', 'title')); | |
}); | |
Route::get('/video/{filename}', function ($filename) { | |
// Pasta dos videos. | |
$videosDir = base_path('resources/assets/videos'); | |
if (file_exists($filePath = $videosDir."/".$filename)) { | |
$stream = new \App\Http\VideoStream($filePath); | |
return response()->stream(function() use ($stream) { | |
$stream->start(); | |
}); | |
} | |
return response("File doesn't exists", 404); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Http; | |
/** | |
* Description of VideoStream | |
* | |
* @author Rana | |
* @link https://gist.github.com/vluzrmos/d5682ad426525196d069 | |
*/ | |
class VideoStream | |
{ | |
/* Visite o link https://gist.github.com/vluzrmos/d5682ad426525196d069 para ver o conteúdo desse arquivo. */ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>{{$title}}</title> | |
<link href="//vjs.zencdn.net/4.12/video-js.css" rel="stylesheet"> | |
</head> | |
<body> | |
<video id="example_video_1" class="video-js vjs-default-skin vjs-big-play-centered" | |
controls preload="auto" height="600" width="980"> | |
<source src="{{url($video)}}" type="{{$mime}}" /> | |
</video> | |
<script src="//vjs.zencdn.net/4.12/video.js"></script> | |
<script> | |
videojs(document.getElementById('example_video_1'), {}, function() { | |
// This is functionally the same as the previous example. | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment