App\Http\Controllers\API\SongController::play PHP Метод

play() публичный Метод

Play/stream a song.
public play ( Song $song, null | boolean $transcode = null, null | integer $bitRate = null ) : Illuminate\Http\RedirectResponse | Redirector
$song app\models\Song The song to stream.
$transcode null | boolean Whether to force transcoding the song. If this is omitted, by default Koel will transcode FLAC.
$bitRate null | integer The target bit rate to transcode, defaults to OUTPUT_BIT_RATE. Only taken into account if $transcode is truthy.
Результат Illuminate\Http\RedirectResponse | Illuminate\Routing\Redirector
    public function play(Song $song, $transcode = null, $bitRate = null)
    {
        if ($song->s3_params) {
            return (new S3Streamer($song))->stream();
        }
        // If `transcode` parameter isn't passed, the default is to only transcode FLAC.
        if ($transcode === null && ends_with(mime_content_type($song->path), 'flac')) {
            $transcode = true;
        }
        $streamer = null;
        if ($transcode) {
            $streamer = new TranscodingStreamer($song, $bitRate ?: config('koel.streaming.bitrate'), request()->input('time', 0));
        } else {
            switch (config('koel.streaming.method')) {
                case 'x-sendfile':
                    $streamer = new XSendFileStreamer($song);
                    break;
                case 'x-accel-redirect':
                    $streamer = new XAccelRedirectStreamer($song);
                    break;
                default:
                    $streamer = new PHPStreamer($song);
                    break;
            }
        }
        $streamer->stream();
    }