Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using fetch for srcing the audio requires downloading the full track before playing #114

Open
simonv3 opened this issue May 5, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@simonv3
Copy link
Collaborator

simonv3 commented May 5, 2022

Using fetch for srcing the audio requires downloading the full track before playing. This causes significant lag between songs and after pressing play.

We do this because we need to send headers on the request to be able to skip CORS and get the full track length. Wonder if there's a way of using the webaudio api to get around this?

https://www.html5rocks.com/en/tutorials/webaudio/intro/

https://middleearmedia.com/web-audio-api-bufferloader/

https://stackoverflow.com/questions/66154042/using-readablestream-as-html-audio-source

https://developer.mozilla.org/en-US/docs/Web/API/Streams_API/Using_readable_streams

https://apiko.com/blog/audio-file-streaming-in-js/

This seems like the most solid intro overview https://stackoverflow.com/questions/52667708/play-audio-from-partial-response-and-save-the-buffer-once-complete, and this one provides important context too https://stackoverflow.com/questions/20134384/web-audio-api-how-to-play-a-stream-of-mp3-chunks

Here's some history on the status of this as a standard WebAudio/web-audio-api#337

@simonv3 simonv3 added the enhancement New feature or request label May 5, 2022
@simonv3
Copy link
Collaborator Author

simonv3 commented May 6, 2022

howler was promising but it only does streaming support with audio tags, which means that it can't do xhr goldfire/howler.js#1134

@simonv3
Copy link
Collaborator Author

simonv3 commented May 6, 2022

phonogram seems worth exploring but it doesn't look like it allows you to set headers on the fetch request. https://github.com/Rich-Harris/phonograph

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant