# Problem with sound.duration

**URL:** <https://forum.kirupa.com/t/problem-with-sound-duration/93586>\
**Category:** Uncategorized\
**Created:** [November 2, 2003, 1:03pm UTC](https://forum.kirupa.com/t/problem-with-sound-duration/93586 "2003-11-02T13:03:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Flashmatazz](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/flashmatazz/32/140_2.png) [@Flashmatazz](https://forum.kirupa.com/u/Flashmatazz)\
**Post date:** [November 2, 2003, 1:03pm UTC](https://forum.kirupa.com/t/problem-with-sound-duration/93586/1 "2003-11-02T13:03:58Z")

</div>

I’ll probably feel embarrassed for overseeing something, but at the moment I’m getting a little frustrated with this, so here goes:

I’m building a simple audioplayer.

In frame 1 I have:

```auto

mySound = new Sound();
songs = new Array("1.mp3", "2.mp3");
songIndex = 0;

mySound.loadSound(this.songs[songIndex], true);

mySound.start();
var playing = true;

this.onEnterFrame = function() {
	if (playing == true){
		totalDuration = mySound.duration/1000;
		totalSeconds = Math.floor(totalDuration%60);
		totalMinutes = Math.floor((totalDuration - totalSeconds)/60);
		if(totalSeconds < 10) totalSeconds = "0" + totalSeconds;
		this.display.track = songs[songIndex] + " - " + totalMinutes + ":" + totalSeconds;
	
		currentPosition = mySound.position/1000;
		currentSeconds = Math.floor(currentPosition%60);
		currentMinutes = Math.floor((currentPosition - currentSeconds)/60);
		if(currentSeconds < 10) currentSeconds = "0" + currentSeconds;
		this.display.timer = currentMinutes + ":" + currentSeconds;
	}
	else {
		currentSeconds = 0;
		currentMinutes = 0;
		this.display.timer = "0:00";
	}
}
MovieClip.prototype.changeTrack = function(x){
	this.songIndex = (this.songIndex+x)%this.songs.length;
	if (this.songIndex<0) {
		this.songIndex += this.songs.length;
	}
	mySound.stop();
	mySound.loadSound(this.songs[songIndex], true);
	mySound.start();
}

```

On my stop-button I have:

```auto

on(release){
	if (_root.playing == true){
		_root.mySound.stop();
		_root.playing = false;
	}
}

```

Ok, so the sound stops, no problem thusfar.

On my play-button I have:

```auto

on(release){
	if(_root.playing != true) {
		_root.mySound.loadSound(_root.songs[songIndex], true);
		_root.mySound.start();
		_root.playing = true;
	}
}

```

So, the sound begins to play from the beginning. However the problem is with the timer: when ‘stop’ is pressed it says _0:00_

But, when I press play again it immediately jumps to the time it showed when _stop_ was pushed, e.g. _0:12_

Please shed a light on this for me, 'cause I’m very confused. :h:

Thanks.
