mediaInformationService = $mediaInformationService; $this->streamerFactory = $streamerFactory; $this->artistRepository = $artistRepository; $this->albumRepository = $albumRepository; } /** * Play/stream a song. * * @link https://github.com/phanan/koel/wiki#streaming-music * * @param null|bool $transcode Whether to force transcoding the song. * If this is omitted, by default Koel will transcode FLAC. * @param null|int $bitRate The target bit rate to transcode, defaults to OUTPUT_BIT_RATE. * Only taken into account if $transcode is truthy. * * @return RedirectResponse|Redirector */ public function play(SongPlayRequest $request, Song $song, ?bool $transcode = null, ?int $bitRate = null) { return $this->streamerFactory ->createStreamer($song, $transcode, $bitRate, floatval($request->time)) ->stream(); } /** * Update songs info. * * @return JsonResponse */ public function update(SongUpdateRequest $request) { $updatedSongs = Song::updateInfo($request->songs, $request->data); return response()->json([ 'artists' => $this->artistRepository->getByIds($updatedSongs->pluck('artist_id')->all()), 'albums' => $this->albumRepository->getByIds($updatedSongs->pluck('album_id')->all()), 'songs' => $updatedSongs, ]); } }