Is it possible to start playing audio using MediaSource (or something) without waiting for the complete data to be received ? For example, I have a very large audio file (several hours long) served using chunked transfer encoding, and I want to play it as soon as possible while the fetching process continues.
I’ve tried to fetch using standard code from MediaSource examples, e.g this. But audio player waits for whole file to be loaded.
2
Answers
Modifying the
MediaSource examples
code you gave, I came up with thisThere’s no reason to do anything wild. It’s this simple:
The
preload="none"
is there for live streams, so that the browser isn’t just downloading audio it isn’t going to play. You can take it out if your stream is not live.Don’t bother with MediaSource Extensions. It does not gain you any functionality for this use case, and only hurts your client compatibility and codec/container choices.