2

When I want to play audio from localhost with a simple HTML5 audio player or any other, and I try to seek into the song, it drops me back to the very beginning of the song and starts it again. I use Laravel 5.5 (the audio file itself is stored in the storage) and probably it is a common problem within the framework. In my opinion, some headers are missing and probably that causes the problem.

Audio headers returned by Laravel:

Audio headers returned by Laravel

I have also found these 2 posts:

Laravel 4.2 serving mp3 - not windable
Laravel 5 HTTP Response, M4V Files, and iOS MPMoviePlayerViewController

But neither of them helped me. Do you have any idea what the problem could be?

milo526
  • 5,012
  • 5
  • 41
  • 60
  • Why do you think this is a laravel problem? Do you have any error logs or something in indicating so? I use laravel with twilio in a couple projects and have no issues with audio what so ever. –  Jan 23 '18 at 09:55
  • I think that, because as I know, Google Chrome needs some correct (additional) headers, not just those on the picture. For example I'm not sure, if that range is correct. I have just tested it on Firefox and as I guessed, it works correctly. Firefox doesn't play media in the same way as Chrome and that's why it works there. – Filip Vucinic Jan 23 '18 at 10:20
  • Can you include your code which is handling your response stream? –  Jan 23 '18 at 10:22
  • https://stackoverflow.com/a/43638044/320487. See if this helps. –  Jan 23 '18 at 10:25
  • Currently I don't use any, but as I said, I tried it with those 2 solutions on the links. My question would be, how to access the file directly from this response that is returned from your link? I mean – Filip Vucinic Jan 23 '18 at 10:54

1 Answers1

0

I tried it on an other PC, with a fresh, stock Laravel and the result is the same, so it is almost sure that this problem exists in the framework. Just to mention, in Chrome it does not seek, while in Firefox it works, because the 2 browsers does not work in the same way.

I simply use the following code to read the file:

<audio controls>
    <source src="/storage/audio.mp3" type="audio/mpeg">
</audio>

Anybody had this problem before?