Menu

class: Audio

[6:14] (extern: com.aussom.aussomscript.AAudio) extends: object

The 'Audio' class provides audio playback support. It supports both URL-based playback through the HTMLAudioElement and buffer-based playback through the Web Audio API.

Methods

  • Audio (string Src = null)

    Creates an Audio object. An optional URL can be provided to set the audio source immediately.

    • @p Src is an optional string with the audio URL.
    • @r A new Audio object.
  • _init (string Src = null)

  • setSrc (string Src)

    Sets the audio source URL.

    • @p Src is a string with the URL.
    • @r this object
  • getSrc ()

    Gets the current audio source URL.

    • @r A string with the URL, or an empty string if not set.
  • play ()

    Starts or resumes playback.

    • @r this object
  • pause ()

    Pauses playback.

    • @r this object
  • stop ()

    Stops playback and resets position to the beginning.

    • @r this object
  • getDuration ()

    Gets the total duration of the audio in seconds.

    • @r A double with the duration, or 0 if unknown.
  • getCurrentTime ()

    Gets the current playback position in seconds.

    • @r A double with the current time.
  • setCurrentTime (double Time)

    Seeks to the given position in seconds.

    • @p Time is a double with the playback position in seconds.
    • @r this object
  • getVolume ()

    Gets the current playback volume.

    • @r A double between 0.0 (silent) and 1.0 (full volume).
  • setVolume (double Volume)

    Sets the playback volume.

    • @p Volume is a double between 0.0 (silent) and 1.0 (full volume).
    • @r this object
  • isMuted ()

    Returns whether playback is muted.

    • @r A bool, true if muted.
  • setMuted (bool Muted)

    Sets the muted state.

    • @p Muted is a bool.
    • @r this object
  • isLoop ()

    Returns whether the audio will loop when it reaches the end.

    • @r A bool, true if looping is enabled.
  • setLoop (bool Loop)

    Sets whether the audio loops.

    • @p Loop is a bool.
    • @r this object
  • isEnded ()

    Returns whether playback has ended.

    • @r A bool, true if the audio has finished playing.
  • isPaused ()

    Returns whether playback is currently paused.

    • @r A bool, true if paused.
  • canPlayType (string Type)

    Tests browser support for an audio MIME type.

    • @p Type is a string such as "audio/mpeg" or "audio/ogg".
    • @r A string: "probably", "maybe", or "" (unsupported).
  • addListener (string Event, callback Handler, object PassedArg = null)

    Registers an event listener on the audio element. Common event names include "play", "pause", "ended", "error", and "timeupdate".

    • @p Event is a string with the event name.
    • @p Handler is a callback invoked as Handler(eventName, passedArg).
    • @p PassedArg is an optional value forwarded to the handler.
    • @r this object
  • playBuffer (object Buf, callback OnEnded = null, callback OnError = null)

    Plays audio from an Aussom buffer using the Web Audio API. The buffer must contain valid encoded audio data (MP3, OGG, WAV, etc.).

    • @p Buf is a buffer with the encoded audio bytes.
    • @p OnEnded is an optional callback invoked when playback finishes.
    • @p OnError is an optional callback invoked with an error string on failure.
    • @r this object