2020-09-07 20:43:23 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use App\Http\Requests\SongPlayRequest;
|
|
|
|
use App\Models\Song;
|
2024-02-24 07:28:49 +00:00
|
|
|
use App\Services\Streamer\Streamer;
|
2020-09-07 20:43:23 +00:00
|
|
|
|
|
|
|
class PlayController extends Controller
|
|
|
|
{
|
2024-02-24 07:28:49 +00:00
|
|
|
public function __invoke(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-02-24 07:28:49 +00:00
|
|
|
return (new Streamer(song: $song, config: [
|
|
|
|
'transcode' => (bool) $transcode,
|
|
|
|
'bit_rate' => $bitRate,
|
|
|
|
'start_time' => (float) $request->time,
|
|
|
|
]))->stream();
|
2020-09-07 20:43:23 +00:00
|
|
|
}
|
|
|
|
}
|