Refactor FrontController::getStream()
This commit is contained in:
parent
879a37820d
commit
1b4e96f5ef
1 changed files with 6 additions and 9 deletions
|
@ -329,23 +329,20 @@ class FrontController
|
||||||
} elseif ($video->protocol == 'rtmp') {
|
} elseif ($video->protocol == 'rtmp') {
|
||||||
$stream = $this->download->getRtmpStream($video);
|
$stream = $this->download->getRtmpStream($video);
|
||||||
$response = $response->withHeader('Content-Type', 'video/'.$video->ext);
|
$response = $response->withHeader('Content-Type', 'video/'.$video->ext);
|
||||||
if ($request->isGet()) {
|
$body = new Stream($stream);
|
||||||
$response = $response->withBody(new Stream($stream));
|
|
||||||
}
|
|
||||||
} elseif ($video->protocol == 'm3u8') {
|
} elseif ($video->protocol == 'm3u8') {
|
||||||
$stream = $this->download->getM3uStream($video);
|
$stream = $this->download->getM3uStream($video);
|
||||||
$response = $response->withHeader('Content-Type', 'video/'.$video->ext);
|
$response = $response->withHeader('Content-Type', 'video/'.$video->ext);
|
||||||
if ($request->isGet()) {
|
$body = new Stream($stream);
|
||||||
$response = $response->withBody(new Stream($stream));
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$client = new \GuzzleHttp\Client();
|
$client = new \GuzzleHttp\Client();
|
||||||
$stream = $client->request('GET', $video->url, ['stream' => true]);
|
$stream = $client->request('GET', $video->url, ['stream' => true]);
|
||||||
$response = $response->withHeader('Content-Type', $stream->getHeader('Content-Type'));
|
$response = $response->withHeader('Content-Type', $stream->getHeader('Content-Type'));
|
||||||
$response = $response->withHeader('Content-Length', $stream->getHeader('Content-Length'));
|
$response = $response->withHeader('Content-Length', $stream->getHeader('Content-Length'));
|
||||||
if ($request->isGet()) {
|
$body = $stream->getBody();
|
||||||
$response = $response->withBody($stream->getBody());
|
|
||||||
}
|
}
|
||||||
|
if ($request->isGet()) {
|
||||||
|
$response = $response->withBody($body);
|
||||||
}
|
}
|
||||||
$response = $response->withHeader(
|
$response = $response->withHeader(
|
||||||
'Content-Disposition',
|
'Content-Disposition',
|
||||||
|
|
Loading…
Reference in a new issue