/    Sign up×
Community /Pin to ProfileBookmark

Length of a WAV/MP3

Hi-
I was wondering if- using oly JavaScript – there is a way to get the length of a WAV or MP3 file embedded in the page. If anyone can help me out, it would be helpful. Thanks everyone in advance.

  • (CONFUSED) IceMetalPunk ?
  • to post a comment
    JavaScript

    2 Comments(s)

    Copy linkTweet thisAlerts:
    @fredmvMar 06.2004 — If you're trying to build some kind of media player, there is a decent solution you could use: simply store the duration of each song in the array (e.g., [font=courier]["1:45", "3:23"][/font]) then you could easily (via the [font=courier]split[/font] method or otherwise) obtain the lengths of each song and run a function to go to the next song based on the duration of each song. Though, it would of course be easier using some kind of API for the embedded media object, that is if there even is one. And, if there is, you'll need some kind of [font=courier]getMediaLength[/font] method.
    Copy linkTweet thisAlerts:
    @IceMetalPunkauthorMar 06.2004 — Actually, I am not trying to make a media player. I am trying to embed a RANDOM song using an array of song sources, and then change the length of that song to milliseconds to close the pop-up the song will be embedded in as soon as the song is over. I guess I will have to put the times in the source array and split from there, but how would I convert minutes and seconds to milliseconds using Javascript?

    -IceMetalPunk
    ×

    Success!

    Help @IceMetalPunk spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 6.2,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,
    )...