views:

527

answers:

1

I am using the below jQuery plugin for playing mp3 www.happyworm.com/jquery/jplayer

However, there is a bug in Flash that the total play (track) time won't show up correctly UNTIL AFTER the whole mp3 is completed downloaded.

I wonder if there is a way to work around this to get the correct total time using either javascript / another flash / even backend library in ASP.NET. Any suggestion helps. Thanks

+1  A: 

You sure that's a bug? Looking at the header definition for the MP3 format I don't see any values for the length of the file. Generally applications that play MP3s would have to calculate the time, and that may not be doable until the entire file is downloaded. So the behavior you're seeing from Flash might be expected.

Theoretically if it's a fixed bitrate file (as opposed to VBR) then knowing the bitrate (gotten from the header) and the total size of the file should be enough to calculate it. However, the server would have to report the size of the file in the response headers (and that's not guaranteed to be accurate).

My guess is you'd need some service on the server that could calculate the length and report that to you in a separate request.

Herms
Yes, I'm not convinced that this is a bug either. There is, however, a start-time and end-time in the ID3 tag (https://secure.wikimedia.org/wikipedia/en/wiki/ID3), but that's the closest there is.
Dan Atkinson
I don't have much knowledge about mp3. So is the ID3 added in mp3 file itself? And if it is not there, nothing we can do about it, right?
HP
Even if it's there you may have trouble getting to it on the client side. For javascript to access it the javascript code would have to download it and process the file. That's separate from the flash player downloading it, so you'll be wasting bandwidth.
Herms