# Song timer

**URL:** <https://forum.kirupa.com/t/song-timer/117343>\
**Category:** Uncategorized\
**Created:** [July 26, 2004, 7:48pm UTC](https://forum.kirupa.com/t/song-timer/117343 "2004-07-26T19:48:05Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jedinitex](https://avatars.discourse-cdn.com/v4/letter/j/34f0e0/32.png) [@jedinitex](https://forum.kirupa.com/u/jedinitex)\
**Post date:** [July 26, 2004, 7:48pm UTC](https://forum.kirupa.com/t/song-timer/117343/1 "2004-07-26T19:48:05Z")

</div>

i have an mp3 playing in my movie and i want a time to show in the media player. i want it to show like this: “current position time/song duration time”. it all works except that when the current position time gets to 31 (seconds) it adds one to the minute side. here’s my code:

```auto

onClipEvent(enterFrame){
 durMinutes = Math.round((mySound.duration/1000)/60);
 var durMinSeconds = durMinutes * 60;
 durSeconds = (Math.round(mySound.duration/1000)) - durMinSeconds;
 posMinutes = Math.round((mySound.position/1000)/60);
 var posMinSeconds = posMinutes * 60;
 posSeconds = Math.round(mySound.position/1000);
 if (posSeconds < 10){
  posSeconds = "0" + posSeconds;
 }
}

```

thanks in advance!

---

<div class="post-metadata">

**Author:** ![bobdoe](https://avatars.discourse-cdn.com/v4/letter/b/51bf81/32.png) [@bobdoe](https://forum.kirupa.com/u/bobdoe)\
**Post date:** [July 26, 2004, 9:59pm UTC](https://forum.kirupa.com/t/song-timer/117343/2 "2004-07-26T21:59:59Z")

</div>

I just applied your code to something in my code and it does do what you say, jumps at 30 or 31 seconds. here’s what to change:  
posMinutes = **int** ((mySound.position/1000)/60);  
im not crazy about the Math.round function since I’m not familiar with what it specifically does with ints and floats.

---

<div class="post-metadata">

**Author:** ![jedinitex](https://avatars.discourse-cdn.com/v4/letter/j/34f0e0/32.png) [@jedinitex](https://forum.kirupa.com/u/jedinitex)\
**Post date:** [July 27, 2004, 7:48pm UTC](https://forum.kirupa.com/t/song-timer/117343/3 "2004-07-27T19:48:44Z")

</div>

it works but now it needs to go back to 00 when it gets past 59. how do i go about that?

---

<div class="post-metadata">

**Author:** ![jedinitex](https://avatars.discourse-cdn.com/v4/letter/j/34f0e0/32.png) [@jedinitex](https://forum.kirupa.com/u/jedinitex)\
**Post date:** [July 28, 2004, 6:35pm UTC](https://forum.kirupa.com/t/song-timer/117343/4 "2004-07-28T18:35:21Z")

</div>

does anyone have any suggestions for that? i’m in a bad time crunch ☹

---

<div class="post-metadata">

**Author:** ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)\
**Post date:** [July 28, 2004, 8:19pm UTC](https://forum.kirupa.com/t/song-timer/117343/5 "2004-07-28T20:19:18Z")

</div>

```auto
onClipEvent (enterFrame) {
	durMinutes = Math.floor((mySound.duration/1000)/60);
	var durMinSeconds = durMinutes*60;
	durSeconds = Math.floor(mySound.duration/1000)-durMinSeconds;
	posMinutes = Math.floor((mySound.position/1000)/60);
	var posMinSeconds = posMinutes*60;
	posSeconds = Math.floor(mySound.position/1000)-posMinutes;
	if (posSeconds<10) {
		posSeconds = "0"+posSeconds;
	}
}

```

??

scotty(-:

---

<div class="post-metadata">

**Author:** ![jedinitex](https://avatars.discourse-cdn.com/v4/letter/j/34f0e0/32.png) [@jedinitex](https://forum.kirupa.com/u/jedinitex)\
**Post date:** [July 31, 2004, 6:46am UTC](https://forum.kirupa.com/t/song-timer/117343/6 "2004-07-31T06:46:09Z")

</div>

nope, that didn’t work ☹ anything else?

---

<div class="post-metadata">

**Author:** ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)\
**Post date:** [July 31, 2004, 8:05am UTC](https://forum.kirupa.com/t/song-timer/117343/7 "2004-07-31T08:05:02Z")

</div>

Oops, my bad, i was thinking about this

```auto
        
onClipEvent (enterFrame) {
        durMinutes = Math.floor((mySound.duration/1000)/60);
        var durMinSeconds = durMinutes*60;
        durSeconds = Math.floor(mySound.duration/1000)-durMinSeconds;
        posMinutes = Math.floor((mySound.position/1000)/60);
        var posMinSeconds = posMinutes*60;
        posSeconds = Math.floor(mySound.position/1000)-posMinSeconds;
        if (posSeconds<10) {
                posSeconds = "0"+posSeconds;
        }
}

```

scotty(-:
