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

Hosting mp3 file #11

Open
Ch0ikyle opened this issue Dec 24, 2019 · 2 comments
Open

Hosting mp3 file #11

Ch0ikyle opened this issue Dec 24, 2019 · 2 comments

Comments

@Ch0ikyle
Copy link

I'm coding API server to be used in mp3 app.
I've used koa-send, koa-static, and just setting mp3 file to response-body.

But, no matter what API the app uses, the app stops. When I sent the length of the MP3 file separately because the app did not seem to accept the length of the MP3 file, it worked on iOS but not on Android.

If I post the same MP3 file on S3 and send request to that URL, it worked well, so I can't understand what the problem is.

Also, if I play music on Safari using my API, it comes out as a live broadcast. (using other sites, it comes in the form of mp3)

If it's a problem that you don't know how long it's playing, why is it the same file, but not on other sites, and not on my API?

Other storage site:

other storage site

My API:

my API

@ralyodio
Copy link

ralyodio commented Feb 6, 2020

i think you'll want to serve out of a static directory for mp3. Checkout how to set a static directory with koa-router.

@adjenks
Copy link

adjenks commented Apr 11, 2020

The server and the browser both need to implement "Range Requests". The audio tag for many browsers make ranged requests when you seek ahead. The server also needs to report the file size. Koa is middleware based, you have to find middleware that will serve static files and will support range requests.

Audio tag documentation mentioning range requests:
https://www.w3.org/TR/html52/semantics-embedded-content.html#example-3abe9ec8

MDN docs about range requests: https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests

Actually I just looked for you, it turns out many libraries use koa-send, which does not support range requests: koajs/send#84

Someone in that issue however points out that you can add range support using this middleware: https://github.com/koajs/koa-range

@jonathanong jonathanong transferred this issue from koajs/koa Apr 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants