ahora reproduce canciones
This commit is contained in:
@@ -72,11 +72,26 @@ class SongController extends Controller
|
||||
return response()->noContent(200);
|
||||
}
|
||||
/**
|
||||
* @return void
|
||||
* @param mixed $id
|
||||
* @param int $id
|
||||
*/
|
||||
public function stream($id):void
|
||||
public function stream($id)
|
||||
{
|
||||
$song = Song::find($id);
|
||||
|
||||
// Stream specified song
|
||||
$this->authorize('view', $song);
|
||||
|
||||
if ($song && Storage::exists($song->path)) {
|
||||
$file = Storage::path($song->path);
|
||||
return response()->stream(function () use ($file) {
|
||||
$stream = fopen($file, 'rb');
|
||||
fpassthru($stream);
|
||||
fclose($stream);
|
||||
}, 200, [
|
||||
'Content-Type' => 'audio/mpeg',
|
||||
'Content-Disposition' => 'inline; filename="' . $file . '"',
|
||||
'Accept-Ranges' => 'bytes',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user