melonJS
    Preparing search index...

    Function duration

    • Get the duration of an audio clip, in seconds.

      With no id, returns the duration of the whole clip; with one, the duration of the region that instance is playing, which differs when the instance was started from a sprite.

      Parameters

      • sound_name: string

        Audio clip name (case-sensitive).

      • Optionalid: number

        Sound instance ID. Omit for the whole clip.

      Returns number

      Duration in seconds, or 0 while the clip is still loading.

      const total = me.audio.duration("theme");