I"m using the sound object and the length for duration and position of my sound object are in milliseconds. How would i go about changing it to minutes?
Instead of 289.384 i would like it to show up as 4:49 (4 minutes and 49 seconds)
I"m using the sound object and the length for duration and position of my sound object are in milliseconds. How would i go about changing it to minutes?
Instead of 289.384 i would like it to show up as 4:49 (4 minutes and 49 seconds)
You can use the % (mod) operator. first you divide 289 by 60 and then use Math.floor to round it down to 4. then to get 49 you do 289%60 which returns the remainder (49) and Math.floor that as well
Thanks man i’ll give that a try. I’m horrible with math.
my counter tutorial goes into how to do that =)
I dont know if Kirupa added it yet or not. If not I can send it to you directly.
[edit] actually I have it zipped online now…
http://www.umbc.edu/interactive/flash/kirupa/countdown.zip
[/edit]
lol thanxs sen. Ignore my PM.
welcome :beam:
Very nice sen. I’ve wanted to know how to do this for a while.
I have looked over the countdown code but I am lost in how I am supposed to convert milliseconds into minutes with this code. I found another code that should do the trick nicely but I can’t for the life of me figure out how to pass it time in milliseconds. It’s right in front of my face no? :te:
http://www.thegoldenmean.com/technique/mp3player04.html
/*******************************
function formatTime()
feed it time in milliseconds; it returns time formatted
minutes:seconds:remainder
*********************************/
function formatTime(theSource) {
var elapsedTime = theSource;
//Minutes
var elapsedM = Math.floor(elapsedTime/60000);
var remaining = elapsedTime - (elapsedM * 60000);
//add a leading zero if it's a single digit number
if (elapsedM < 10) {
elapsedM = "0"+elapsedM;
}
//Seconds
var elapsedS = Math.floor(remaining/1000);
remaining -= (elapsedS*1000);
////add leading zero
if (elapsedS<10) {
elapsedS = "0"+elapsedS;
}
//Hundredths
var elapsedFractions = Math.floor(remaining/10);
if (elapsedFractions < 10) {
elapsedFractions = "0"+elapsedFractions;
}
//display result nicely
outputData = elapsedM+":"+elapsedS+":"+elapsedFractions;
return outputData;
}
How does one pass time to this function?
:: Copyright KIRUPA 2024 //--