PDA

View Full Version : Sound.length with streaming mp3



alex_h
October 4th, 2007, 04:21 AM
I'm working on an online audio player that plays streaming mp3s. I have a combined download progress and playback progress display. The download progress element works fine using Sound.bytesLoaded / Sound.bytesTotal as normal. I want to use SoundChannel.position and Sound.length in a similar way in order to display the current playback position within the song. However, although this works fine when testing locally(since the entire mp3 is buffered more or less immediately), as soon as I run it over http I have a problem, because the value returned by Sound.length appears to be dependent on how much of the file has currently downloaded. Since it takes some time for the file to download, I end up with a steadily increasing value being returned by Sound.length, which screws up my progress display.

Can anyone suggest an effective workaround for this? Or am I missing something really obvious... ;)

cheers,

Alex H

Zaid_W1red
October 4th, 2007, 07:28 AM
Yep yer correct...I found this: http://www.actionscript.org/forums/showthread.php3?s=&threadid=27620

A while back but havent tried it...let me know how it works out for ya :)

alex_h
October 4th, 2007, 08:46 AM
cheers for the link Zaid_W1red,

I had a read through that thread, but there aren't really any viable solutions suggested, other than using PHP to get the duration of the mp3 before loading it.
I'd prefer to work around this issue using Actionscript alone, if thats at all possible!

Any other suggestions?

cheers,

Alex H

alex_h
October 4th, 2007, 12:23 PM
I found the answer on flashkit forum - you just multiply the (position/ {reported} length) by the (bytesloaded/ bytestotal) and hey presto...