Table of Contents

Class Jukebox

Namespace
S1API.Audio
Assembly
S1API.dll

Provides managed access to a placed native jukebox.

public sealed class Jukebox
Inheritance
Jukebox
Inherited Members
Extension Methods

Remarks

This wrapper exposes only tracks configured by the game. Controls use the native jukebox methods, including its existing authority, replication, and persistence behavior.

Properties

CurrentTrack

Gets the current native track, or null when none is selected.

public JukeboxTrack? CurrentTrack { get; }

Property Value

JukeboxTrack

CurrentTrackOrderIndex

Gets the current position in the native playback queue.

public int CurrentTrackOrderIndex { get; }

Property Value

int

CurrentTrackTime

Gets the elapsed time of the current track in seconds.

public float CurrentTrackTime { get; }

Property Value

float

GUID

Gets the placed-object identifier assigned by the game.

public string GUID { get; }

Property Value

string

GameObject

Gets the game object that owns the native jukebox.

public GameObject GameObject { get; }

Property Value

GameObject

IsPlaying

Gets whether the jukebox is playing.

public bool IsPlaying { get; }

Property Value

bool

NormalizedVolume

Gets the native volume normalized by the game's maximum volume.

public float NormalizedVolume { get; }

Property Value

float

RepeatMode

Gets the native repeat mode.

public JukeboxRepeatMode RepeatMode { get; }

Property Value

JukeboxRepeatMode

Shuffle

Gets whether the native playback queue is shuffled.

public bool Shuffle { get; }

Property Value

bool

State

Gets an immutable snapshot of the jukebox's current state.

public JukeboxState State { get; }

Property Value

JukeboxState

Sync

Gets whether the jukebox synchronizes with other native jukeboxes.

public bool Sync { get; }

Property Value

bool

Tracks

Gets an immutable snapshot of tracks configured on this jukebox.

public IReadOnlyList<JukeboxTrack> Tracks { get; }

Property Value

IReadOnlyList<JukeboxTrack>

Volume

Gets the current native volume value.

public int Volume { get; }

Property Value

int

Methods

ChangeVolume(int)

Changes the volume using the native jukebox control.

public void ChangeVolume(int change)

Parameters

change int

The change to apply to the current native volume, which the game clamps from 0 through 8.

FromGameObject(GameObject)

Gets the jukebox component on a game object.

public static Jukebox? FromGameObject(GameObject gameObject)

Parameters

gameObject GameObject

The game object to inspect.

Returns

Jukebox

A managed jukebox wrapper, or null when no jukebox is attached.

Exceptions

ArgumentNullException

gameObject is null or destroyed.

NextTrack()

Selects the next track using the native jukebox control.

public void NextTrack()

PreviousTrack()

Selects the previous track using the native jukebox control.

public void PreviousTrack()

SelectTrack(int)

Selects a configured native track.

public void SelectTrack(int trackIndex)

Parameters

trackIndex int

The Index of the configured track.

Exceptions

ArgumentOutOfRangeException

trackIndex does not identify a configured track.

SetVolume(int)

Sets the volume and requests native replication.

public void SetVolume(int volume)

Parameters

volume int

The native volume value to set. The game clamps the value from 0 through 8.

TogglePlay()

Toggles playback using the native jukebox control.

public void TogglePlay()

ToggleRepeatMode()

Cycles the native repeat mode.

public void ToggleRepeatMode()

ToggleShuffle()

Toggles native queue shuffling.

public void ToggleShuffle()

ToggleSync()

Toggles native jukebox synchronization.

public void ToggleSync()

Events

OnStateChanged

Occurs when the native jukebox reports a state change.

public event Action<JukeboxState> OnStateChanged

Event Type

Action<JukeboxState>