php - Response::view triggers download in Laravel

505

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)?

People are also looking for solutions to the problem: jquery - PHP updating SESSION or COOKIE via AJAX

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.