2020-09-07 20:43:23 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use App\Http\Requests\SongPlayRequest;
|
|
|
|
use App\Models\Song;
|
2024-02-05 13:27:17 +00:00
|
|
|
use App\Services\Streamers\StreamerFactory;
|
2020-09-07 20:43:23 +00:00
|
|
|
|
|
|
|
class PlayController extends Controller
|
|
|
|
{
|
2024-01-03 17:02:18 +00:00
|
|
|
public function __invoke(
|
|
|
|
StreamerFactory $streamerFactory,
|
|
|
|
SongPlayRequest $request,
|
|
|
|
Song $song,
|
|
|
|
?bool $transcode = null,
|
|
|
|
?int $bitRate = null
|
|
|
|
) {
|
2024-01-09 11:53:35 +00:00
|
|
|
$this->authorize('access', $song);
|
2020-09-07 20:43:23 +00:00
|
|
|
|
2024-01-03 17:02:18 +00:00
|
|
|
return $streamerFactory
|
2022-07-29 06:47:10 +00:00
|
|
|
->createStreamer($song, $transcode, $bitRate, (float) $request->time)
|
2020-09-07 20:43:23 +00:00
|
|
|
->stream();
|
|
|
|
}
|
|
|
|
}
|