A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Timer for Audio

  1. #1
    strandedgenius.com
    Join Date
    Apr 2005
    Location
    Toronto
    Posts
    187

    Timer for Audio

    I have my audio loaded from an external swf. The audio itself is on the timeline and it's set to stream. Now how would I get it to display the time that has elapsed in minutes and seconds. I think getTimer might work but it only brings back the frames I believe. How would I correct this problem? Do the fps matter?
    JScarlip,
    That Was Nice!

  2. #2
    climbing shoots and ladders feigner's Avatar
    Join Date
    Jun 2003
    Location
    IOP
    Posts
    263
    if it returns frames, then divide the frames by the fps and that will give you seconds.
    FEIGNER
    Before you post, do you search?

  3. #3
    strandedgenius.com
    Join Date
    Apr 2005
    Location
    Toronto
    Posts
    187
    I can't even get the frames. I'm not very familiar with getTimer, just point me in the right direction and I'll figure it out.
    JScarlip,
    That Was Nice!

  4. #4
    climbing shoots and ladders feigner's Avatar
    Join Date
    Jun 2003
    Location
    IOP
    Posts
    263
    what the getTimer function does is return the number of miliseconds that have passed since the movie started playing. So you could set up some code like this...
    code:
    onClipEvent(enterFrame) {
    time = getTimer();
    }

    ...the number of miliseconds that have passed since the start of the movie would be stored in the 'time' variable.

    What i think may work in your situation is when you start playing your audio piece, store the time that has passed in a variable (let's call it "startTime"), then while the audio plays, again get the time that has elapsed, but subtract "startTime" from that time, and that will give you the number of miliseconds since your audio started playing. And you can naturally work out the seconds and minutes from that.
    FEIGNER
    Before you post, do you search?

  5. #5
    strandedgenius.com
    Join Date
    Apr 2005
    Location
    Toronto
    Posts
    187
    alright so now I got the jist of how it works, and I think I get your idea. will onClipEvent(enterFrame) work in this situation. cause the timer won't start until I press play, and if I pause it and play it again will the timer pick up where I left off? or if I fast forward and rewind will it still work. Cause I know getTimer returns the time a movie has been loaded in milliseconds, is there anything else that would actually return the frame number that the movie is on? That way divide by the number of fps to get the seconds that have been played. Would that work with a streamed audio file on the timeline?

    Check out my site and you'll see what I mean or check out the attachement. Maybe you can fix it up a little. (wink wink)

    http://strandedgenius.com/stranded2.html (go to the radio, then to the instrumental section)
    Attached Files Attached Files
    Last edited by jscarlip; 06-30-2005 at 02:23 AM.
    JScarlip,
    That Was Nice!

  6. #6
    strandedgenius.com
    Join Date
    Apr 2005
    Location
    Toronto
    Posts
    187
    Can nobody help me?
    JScarlip,
    That Was Nice!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center