I have some problems with serving mp3's with Laravel 4.2 I have some files which should be played by flashplayer.
public function get($filename)
{
$file = new Symfony\Component\HttpFoundation\File\File(storage_path().DbConfig::get('system.upload_dir').'/'.DbConfig::get('system.upload_music').'/'.$filename);
$response = Response::make(file_get_contents(storage_path().DbConfig::get('system.upload_dir').'/'.DbConfig::get('system.upload_music').'/'.$filename));
$response->header('Content-Type', $file->getMimeType());
$response->header('Content-Length', $file->getSize());
$response->header('Content-Transfer-Encoding', '');
$response->header('Accept-Range', 'bytes');
$response->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
$response->header('Connection', 'Keep-Alive');
return $response;
}
This serves the file - if opened in chrome it lounches chrome's default player and the music plays, the same thing is when I louch it with a flashplayer.
But I'm not able to wind the record. If I serve the file with apache (instead of Laravel controller) it works fine.
I would be grateful if anyone could help me with this issue.
UPDATE
Headers when served via Laravel:
HTTP/1.1 200 OK
Date: Thu, 01 Oct 2015 18:43:59 GMT
Server: Apache/2
Cache-Control: must-revalidate, post-check=0, pre-check=0, private
Content-Transfer-Encoding:
Accept-Range: bytes
Connection: Keep-Alive, Keep-Alive
Set-Cookie: laravel_session=eyJ[...]D; expires=Thu, 01-Oct-2015 20:44:00 GMT; Max-Age=7200; path=/; httponly
Vary: Accept-Encoding,User-Agent
Keep-Alive: timeout=2, max=100
Transfer-Encoding: chunked
Content-Type: audio/mpeg
Headers when served without Laravel:
HTTP/1.1 200 OK
Date: Thu, 01 Oct 2015 18:51:16 GMT
Server: Apache/2
Last-Modified: Fri, 13 Mar 2015 04:03:23 GMT
ETag: "ead61-5112394e338c0"
Accept-Ranges: bytes
Content-Length: 961889
Keep-Alive: timeout=2, max=100
Connection: Keep-Alive
Content-Type: audio/mpeg