is it possible to get the duration of a streaming mp3 in Flash
-
23-09-2019 - |
Question
I'm wondering if it is at all possible to get the total duration of an mp3 being streamed in flash?
At the moment I'm using the following code to estimate the lenght but it is always inaccurate
var loadTime:Number=_track.bytesLoaded / _track.bytesTotal;
var loadPercent:uint=Math.round(100 * loadTime);
estimatedLength=Math.ceil(_track.length / (loadTime));
Solution 3
The long and short of it is if you are playing a streaming mp3 in flash it is impossible to get the exact total playing time until the mp3 is completely downloaded
OTHER TIPS
I don't program in AS3, but can you not read the Length attribtue in the header of the file prior to streaming it?
Sound
class has a length
property. This property will be populated once the relevant id3
data for the sound file is loaded. Check out flash.events.Event.ID3 for more info on id3
data.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow