It turns out that jPlayer supports the HTML5 preload
argument, such that adding preload: 'auto'
to the jPlayer constructor options fixes this problem and displays the track duration. However, this also downloads the whole audio file, which is annoying, because it can use a lot of bandwidth for an audio track that the user may never play. And it's even worse in my case, because I've got a page with a dozen user stories, and the page downloads all of them.
Frustratingly, there's an option preload: 'metadata'
, which sounds like it should do exactly what I want, namely, download the track metadata without downloading the whole file, but this doesn't seem to work. This is apparently something that browsers should support, but don't yet.
For now, I'll either skip this feature, or build a server side piece to check the duration and stream it via separate AJAX call.