php - Response::view triggers download in Laravel
I am trying to display an HTTP Live Streaming playlist (m3u8 file) which is being generated by Laravel. In order to do this, I have a view (playlist.blade.php):
#EXTM3U
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-TARGETDURATION:5
#EXT-X-MEDIA-SEQUENCE:0
@foreach($videos as $video)
#EXTINF:4,
/videos/watch/{{ $video->file }}.ts
@endforeach
#EXT-X-ENDLIST
In my controller, I'm using the following code:
return Response::view('compilations.playlist', compact('videos'))->header('Content-Type', 'application/x-mpegurl');
To make up the view with the right headers.
When I throw up the file onto a static server like nginx, with the correct mime-type, the file displays in the browser, and works with Apple'smediastreamvalidator
. When I try to access the file through the Laravel server, the browser downloads the file automatically (instead of displaying it) and it does not work with themediastreamvalidator
.
How can I make up the view, with the correct headers, and have it behave as the nginx server does (display in the browser, load properly in the verification tool / video players)?