1 Reply Latest reply on Jul 20, 2006 5:25 PM by funkysoul

    Milliseconds to Seconds Minutes

      is there a way to take a number (specifically the position in milliseconds that a sound has been playing) and convert it into minute:second format? any help?

        • 1. Re: Milliseconds to Seconds Minutes
          funkysoul Level 4
          Hi Jeff

          Here a code snippet that I'm using for my flash mp3 player.

          function timer(sound_obj) {
          time = sound_obj.position/1000;
          min = Math.floor(time/60);
          min = (min<10) ? "0"+min : min;
          sec = Math.floor(time%60);
          sec = (sec<10) ? "0"+sec : sec;
          timeDisplay_txt.text = min+":"+sec+"/"+totalDuration;
          function duration() {
          timed = _root.sound_mc.sound_obj.duration/1000;
          mind = Math.floor(timed/60);
          mind = (mind<10) ? "0"+mind : mind;
          secd = Math.floor(timed%60);
          secd = (secd<10) ? "0"+secd : secd;
          totalDuration = mind+":"+secd;

          keep in mind to create a textfield with the instancename of "timeDisplay_txt" and to call the timer function at least every second using the setInterval statement.