Last active
December 30, 2017 02:46
-
-
Save cclloyd/72b5939c99e19cd378dbd5159e2ae156 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
public function clipGetVideo($request, $response, $args) { | |
$clipid = $args['clipid']; | |
$clip = GameClip::where('id', $clipid)->first(); | |
$fh = fopen($clip->File, 'rb'); | |
$stream = new \Slim\Http\Stream($fh); | |
$file_size = filesize($clip->File); | |
$seek_end = (empty($seek_end)) ? ($file_size - 1) : min(abs(intval($seek_end)),($file_size - 1)); | |
$seek_start = (empty($seek_start) || $seek_end < abs(intval($seek_start))) ? 0 : max(abs(intval($seek_start)),0); | |
$response = $response | |
->withBody($stream) | |
->withHeader('Content-type', 'video/mp4') | |
->withHeader('Content-length', filesize($clip->File)) | |
->withHeader('Content-Range', sprintf("bytes %d-%d/%d", $seek_start, $seek_end, $file_size)) | |
->withStatus(206); | |
return $response; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment