PDA

View Full Version : Mp3 File Position in minutes and seconds


Stagalee
03-02-2004, 01:22 PM
This is what I would like to have:
2:30 <--- is the length of a particular mp3 file.
When the file starts to play, I want the position to count from 1 second to 2:30 total length ... You know like on a cd player right, with the colon... every 60seconds goes to a minute ... YEH ok

This is what I have:
150 <---- that is in seconds of the mp3 file - I don't want that.
this is the script I am using:


//MP3 File
mySound_sound = new Sound(this);
mySound_sound.attachSound("track 1");
mySound_sound.start();



//My Problem - only counts in seconds without the colon
position_txt.text = Math.round(mySound_sound.position/1000);

nthpixel
03-02-2004, 06:06 PM
Define two variables.

minutes = (Math.round(mySound_sound.position/1000))/60;
seconds = (Math.round(mySound_sound.position/1000)%60;

position_txt.text = minutes + ":" + seconds;

Stagalee
03-03-2004, 12:23 PM
Thank You