Cluster Creator Kit Script Reference
    Preparing search index...

    Interface AudioStream

    A handle that represents the audio playback stream of an item. The audio playback stream is used to play dynamic audio.

    The audio data of AudioRecord added to the buffer of the audio playback stream is expected to be played sequentially in the order it was added. For reasons such as network conditions, part or all of the audio of the audio playback stream may become inaudible.

    interface AudioStream {
        isPlaying: boolean;
        volume: number;
        add(record: AudioRecord): void;
        attach(subNode: SubNode): void;
        attachToRoot(): void;
        start(): boolean;
        stop(): void;
    }
    Index

    Properties

    isPlaying: boolean

    Gets whether the audio playback stream is currently playing. This property cannot be accessed at the top level of the script.

    volume: number

    A property that represents the volume of the audio playback stream. This property cannot be accessed at the top level of the script.

    The default is 1. The volume can be a number between 0 and 2.5.

    Methods

    • If called while the audio playback stream is playing, adds the audio data to the end of the buffer of the audio playback stream. This API cannot be called at the top level of the script.

      Audio data added to the stream can be heard by players who are in the Space at the time AudioStream.add is called. Players who join later may not be able to hear audio data added before they joined.

      Results in an error if called while the audio playback stream is not playing.

      Parameters

      • record: AudioRecord

        The audio data to add to the stream

      Returns void

    • Specifies the SubNode that serves as the spatial origin of the audio playback stream within the space. This API cannot be called at the top level of the script.

      By default, the spatial origin of the audio playback stream is the item's root position.
      If a non-existent SubNode is specified, the spatial origin of the audio playback stream will be set to the item's root position.

      Parameters

      Returns void

    • Sets the spatial origin of the audio playback stream to the item's root position. This API cannot be called at the top level of the script.

      Returns void

    • Starts a new audio playback stream. This API cannot be called at the top level of the script.

      If called while the audio playback stream is playing, the currently playing audio playback stream is immediately stopped and the buffer of the audio playback stream is cleared.

      Items in a space can have at most 4 audio playback streams playing simultaneously across the entire space. If the limit is exceeded, a new audio playback stream cannot be started.

      Returns boolean

      Returns true if the stream was started successfully. Returns false if it failed.

    • Stops the audio playback stream. This API cannot be called at the top level of the script.

      If called while the audio playback stream is playing, the currently playing audio playback stream is immediately stopped and the buffer of the audio playback stream is cleared.

      Does nothing if called while the audio playback stream is not playing.

      Returns void