Kathirvel K

Display sound play time in FLASH

Posted on: December 24, 2009


function convertTime(t, type) {
var time = Math.ceil(t);
var min = Math.floor(time/60);
var secs = time-(min*60);
return min+”:”+strPad(time%60, 2, 0, “left”);
}

function strPad(str, places, pad, side) {
while (str.length<places) {
if (side == “left”) {
str = pad+str;
} else {
str = str+pad;
}
}

var lengthTester = str.toString();
if (lengthTester.length<=1) {
str = “0”+str;
}
return str;
}

// you call that function like this

convertTime(sound.position/1000);

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: