A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: audio player song duration

  1. #1
    Junior Member
    Join Date
    Oct 2009
    Posts
    17

    audio player song duration

    Im looking for a why to display the current time position of a song playing in an audio player in a dynamic text box.

    I know the soundChannel.position references the current point of the songs, but I need some conceptual help translating that to a string and 00:00 time format dynamic text box

  2. #2
    var timeString = toTimeCode(int(songTimePositioin))

    function toTimeCode(milliseconds:int) : String
    {
    var isNegative:Boolean = false;
    if (milliseconds < 0)
    {
    isNegative = true;
    milliseconds = Math.abs(milliseconds);
    }

    var seconds:int;// = Math.round((milliseconds/1000) % 60);
    seconds = ((milliseconds % (1000*60*60)) % (1000*60)) / 1000
    var strSeconds:String = (seconds < 10) ? ("0" + String(seconds)) : String(seconds);
    if(seconds == 60) strMinutes = "00";
    var minutes:int;// = Math.round(Math.floor((milliseconds/1000)/60));
    minutes = (milliseconds % (1000*60*60)) / (1000*60)
    //var strMinutes:String = (minutes < 10) ? ("0" + String(minutes)) : String(minutes);
    var strMinutes:String = String(minutes);
    var hours:int;
    hours = milliseconds / (1000*60*60)
    var strHours:String = String(hours);
    /*if(minutes > 60)
    {
    strSeconds = "60";
    strMinutes = "00";
    }*/
    var timeCodeAbsolute:String;
    if(hours>0)timeCodeAbsolute = strHours + ":" +strMinutes + ":" + strSeconds;
    else timeCodeAbsolute = strMinutes + ":" + strSeconds;


    var timeCode:String = (isNegative) ? "-" + timeCodeAbsolute : timeCodeAbsolute;
    return timeCode;
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center