Table of Contents

Class Track

Namespace
Nyra.Entities
Assembly
Nyra.dll

An audio track, as returned by load results, player updates and playback events.

public sealed record Track : IEquatable<Track>
Inheritance
Track
Implements
Inherited Members
Extension Methods

Fields

MaxDecodeVersion

Highest encoding version the decoder understands, v1 carries no URI, v2 adds it, v3 adds artwork URL and ISRC.

public const int MaxDecodeVersion = 3

Field Value

int

Properties

Encoded

Base64-encoded track string, used to play it back.

[JsonPropertyName("encoded")]
[JsonInclude]
public string Encoded { get; }

Property Value

string

Remarks

Absorbs a null encoded the server sends, the setter substitutes the empty string, so a consumer reading its length or comparing it never dereferences null.

Info

The descriptive info of the track.

[JsonPropertyName("info")]
[JsonInclude]
public TrackInfo Info { get; }

Property Value

TrackInfo

Remarks

Absorbs a null info the server sends, the setter substitutes a fresh instance, so comparisons and printing never read null.

PluginInfo

The plugin data the server attached to the track, raw JSON.

[JsonPropertyName("pluginInfo")]
[JsonInclude]
public JsonElement? PluginInfo { get; }

Property Value

JsonElement?

StartPosition

Start offset from the source link's t/start parameter, client-side only.

[JsonIgnore]
public TimeSpan? StartPosition { get; }

Property Value

TimeSpan?

Remarks

It travels as the position of the play update on every play of the instance (an explicit StartPosition wins) and is consumed per instance. Only a play that could not have been refused (no NoReplace, or a player with nothing playing) nulls it on the track itself. A track shared between guilds therefore loses the offset for all of them, so clone the track (record with) per consumer.

The consumption is best-effort on the play's echo, a play the server silently ignored (NodeLink drops a re-sent identical track) can consume it without a restart, and a NoReplace refusal caused by a concurrent same-track play consumes it too. The next accepted play then starts from zero.

UserData

Track data previously stored by a client through the update-player endpoint.

[JsonPropertyName("userData")]
[JsonInclude]
public JsonElement? UserData { get; }

Property Value

JsonElement?

Methods

Decode(string)

Decodes a base64 track locally, without contacting the server.

public static Track Decode(string encodedTrack)

Parameters

encodedTrack string

The base64 track to decode.

Returns

Track

The decoded track, position included.

Remarks

The size word of the header delimits the message, and the position is read from the message's final 8 bytes. Source-specific data before it and any appendix an encoder wrote after the message are ignored.

Exceptions

ArgumentNullException

The track argument is null.

InvalidTrackException

The track is blank (empty or whitespace), is not valid base64, has a message size out of bounds, is truncated, uses an unsupported version or is malformed.

Equals(Track?)

Indicates whether the tracks carry the same encoding, info and raw plugin data.

public bool Equals(Track? other)

Parameters

other Track

The track to compare with.

Returns

bool

Whether the tracks are equal, raw members compared by content.

GetHashCode()

Returns the hash code of the track.

public override int GetHashCode()

Returns

int

A hash of the encoding and info, the raw members and the start offset stay out of it.

ToString()

Returns the track as its info.

public override string ToString()

Returns

string

The track's info.