2020-09-07 20:43:23 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use App\Factories\StreamerFactory;
|
|
|
|
use App\Http\Requests\SongPlayRequest;
|
|
|
|
use App\Models\Song;
|
|
|
|
|
|
|
|
class PlayController extends Controller
|
|
|
|
{
|
2021-06-05 10:47:56 +00:00
|
|
|
private StreamerFactory $streamerFactory;
|
2020-09-07 20:43:23 +00:00
|
|
|
|
2021-06-05 10:47:56 +00:00
|
|
|
public function __construct(StreamerFactory $streamerFactory)
|
2020-09-07 20:43:23 +00:00
|
|
|
{
|
|
|
|
$this->streamerFactory = $streamerFactory;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function show(SongPlayRequest $request, Song $song, ?bool $transcode = null, ?int $bitRate = null)
|
|
|
|
{
|
|
|
|
return $this->streamerFactory
|
|
|
|
->createStreamer($song, $transcode, $bitRate, floatval($request->time))
|
|
|
|
->stream();
|
|
|
|
}
|
|
|
|
}
|