Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Audio

Hierarchy

Index

Constructors

constructor

  • new Audio(source: string, volume?: number, radio?: boolean, clearCache?: boolean): Audio
  • Creates a new Audio instance.

    Parameters

    • source: string

      The source url of the audio.

    • Optional volume: number

      The volume of the audio. Ranges from 0 to 1.

    • Optional radio: boolean
    • Optional clearCache: boolean

    Returns Audio

Properties

Readonly currentTime

currentTime: number

Readonly id

id: number

Readonly isRemote

isRemote: boolean

Whether this entity was created clientside or serverside. (Clientside = false, Serverside = true).

looped

looped: boolean

Readonly maxTime

maxTime: number

Readonly playing

playing: boolean

Readonly refCount

refCount: number

Returns the ref count of the entity.

remarks

It's only available in debug-mode.

Readonly remoteID

remoteID: number

The serverside id of this entity.

source

source: string

Readonly type

Type of the object.

Readonly valid

valid: boolean

Object usability.

returns

False if object is no longer usable.

volume

volume: number

Static Readonly all

all: readonly Audio[]

Static Readonly count

count: number

Methods

addOutput

  • remarks

    This method has no effect if the {@link frontendPlay} property returns true.

    Parameters

    Returns void

deleteMeta

  • deleteMeta(key: string): void
  • deleteMeta<K>(key: K): void

destroy

  • destroy(): void
  • Removes the object from the world.

    Returns void

getMeta

  • getMeta<K>(key: Exclude<K, keyof ICustomAudioMeta>): unknown
  • getMeta<K>(key: K): ICustomAudioMeta[K] | undefined
  • getMeta<V>(key: string): V | undefined
  • Type parameters

    • K: string

    Parameters

    Returns unknown

  • Type parameters

    Parameters

    • key: K

    Returns ICustomAudioMeta[K] | undefined

  • deprecated

    See ICustomAudioMeta

    Type parameters

    • V: any

    Parameters

    • key: string

    Returns V | undefined

getMetaDataKeys

  • getMetaDataKeys(): readonly string[]

getOutputs

  • remarks

    This method has no effect if the {@link frontendPlay} property returns true.

    Returns readonly (AudioOutput | number)[]

getSyncedMeta

  • getSyncedMeta<K>(key: Exclude<K, keyof ICustomBaseObjectSyncedMeta>): unknown
  • getSyncedMeta<K>(key: K): ICustomBaseObjectSyncedMeta[K] | undefined
  • getSyncedMeta<V>(key: string): V | undefined

getSyncedMetaKeys

  • getSyncedMetaKeys(): readonly string[]

hasMeta

  • hasMeta(key: string): boolean
  • hasMeta<K>(key: K): boolean
  • Parameters

    • key: string

    Returns boolean

  • Type parameters

    Parameters

    • key: K

    Returns boolean

hasSyncedMeta

  • hasSyncedMeta(key: string): boolean
  • hasSyncedMeta<K>(key: K): boolean
  • Determines whether contains the specified key.

    Parameters

    • key: string

      The key of the value to locate.

    Returns boolean

    True if the meta table contains any data at the specified key or False if not

  • Type parameters

    Parameters

    • key: K

    Returns boolean

on

  • on(event: "inited", callback: () => void): void
  • on(event: "streamStarted", callback: () => void): void
  • on(event: "streamEnded", callback: () => void): void
  • on(event: "streamPaused", callback: () => void): void
  • on(event: "streamReset", callback: () => void): void
  • on(event: "streamSeek", callback: (time: number) => void): void
  • on(event: "volumeChange", callback: (vol: number) => void): void
  • on(event: "error", callback: (code: number, message: string) => void): void
  • Parameters

    • event: "inited"
    • callback: () => void
        • (): void
        • Returns void

    Returns void

  • Parameters

    • event: "streamStarted"
    • callback: () => void
        • (): void
        • Returns void

    Returns void

  • Parameters

    • event: "streamEnded"
    • callback: () => void
        • (): void
        • Returns void

    Returns void

  • Parameters

    • event: "streamPaused"
    • callback: () => void
        • (): void
        • Returns void

    Returns void

  • Parameters

    • event: "streamReset"
    • callback: () => void
        • (): void
        • Returns void

    Returns void

  • Parameters

    • event: "streamSeek"
    • callback: (time: number) => void
        • (time: number): void
        • Parameters

          • time: number

          Returns void

    Returns void

  • Parameters

    • event: "volumeChange"
    • callback: (vol: number) => void
        • (vol: number): void
        • Parameters

          • vol: number

          Returns void

    Returns void

  • Parameters

    • event: "error"
    • callback: (code: number, message: string) => void
        • (code: number, message: string): void
        • Parameters

          • code: number
          • message: string

          Returns void

    Returns void

pause

  • pause(): void
  • Returns void

play

  • play(): void
  • Returns void

removeOutput

  • remarks

    This method has no effect if the {@link frontendPlay} property returns true.

    Parameters

    Returns void

reset

  • reset(): void
  • Returns void

seek

  • seek(time: number): void
  • Parameters

    • time: number

    Returns void

setMeta

  • setMeta<K>(key: K, value: shared.InterfaceValueByKey<ICustomAudioMeta, K>): void
  • setMeta<K>(key: K, value: ICustomAudioMeta[K]): void
  • setMeta<V, K>(key: K, value: shared.InterfaceValueByKey<ICustomAudioMeta, K, V>): void
  • Type parameters

    • K: string

    Parameters

    Returns void

  • Type parameters

    Parameters

    • key: K
    • value: ICustomAudioMeta[K]

    Returns void

  • deprecated

    See ICustomAudioMeta

    Type parameters

    • V: any

    • K: string = string

    Parameters

    Returns void

Static getByID

  • getByID(id: number): Audio | null
  • Retrieves the audio from the pool.

    Parameters

    • id: number

      The id of the audio.

    Returns Audio | null

    Entity if it was found, otherwise null.

Static getByRemoteID