I have a node.js server converting and streaming mp3’s on the fly.
I am using an HTML5 audio tag to consume this stream, and the issue I’m having is the audio element doesn’t know the duration of the mp3 until it has finished playing the whole thing (obviously).
Is there any way, since my server knows the duration of the mp3 before sending it, that I can include the duration in the header of the response from the server or something, so the client consuming it knows the duration?
Thanks
I think for the time-being, in terms of a widely-supported solution, you’re stuck sending that stuff through a separate request (or otherwise within some sort of manifest of your links — included in the playlist you use to point at appropriate URIs, for example). This, of course, could be generated by your server, dynamically, when the songs are first added, and then served statically from then, on.
In a media-player which I’m building, I’m doing something similar to this — downloading a json file which contains what would typically be within .mp3 metadata (which will also support non-mp3 versions, et cetera).
This is far from ideal, but again is one of those things that html5 audio/video wasn’t meant to solve in its first iteration.