3 Replies Latest reply on Feb 4, 2007 12:51 PM by abeall

    Get the real duration

    Natan Alves Level 1

      I am creating a MP3 Player using XML. I have one problem, get the real duration from the mp3 file when the file is not complete loaded (using the streaming from the Sound Class). Search on the web and i found many topics, but none resolution.

      I create an function to show the current play progress from the music:

      function soundProgress() {
      mySoundBytesTotal = som.getBytesTotal();
      mySoundBytesLoaded = som.getBytesLoaded();
      mySoundLoading = Math.round((mySoundBytesLoaded/mySoundBytesTotal)*100);
      barLoad._xscale = (som.position/som.duration)*mySoundLoading;

      Where som is the instance of the sound and the barLoad is the MovieClip that i create to show the progress.

      From that code, i created another function to compare the current position and stipulate the duration:

      function duraction() {
      if (som.position>0 && som.duration>0 && barLoad._xscale>0) {
      duration_txt.text = Math.floor((((som.position*100)/barLoad._xscale)/1000)/60)+":"+Math.floor((((som.position *100)/barLoad._xscale)/1000)%60);

      But, this works when the music is complete loaded or when the swf and the mp3 files is in my computer.

      So, somebody have the soluction to help me, because this is the only thing that lacks to finish.


      Ps: sorry for my English