koel/app/Http/Controllers/PlayController.php

22 lines
560 B
PHP
Raw Normal View History

<?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;
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);
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();
}
}