Class NodeTracks
- Namespace
- Nyra
- Assembly
- Nyra.dll
Decoding, encoding and streaming of the tracks of a node.
public sealed class NodeTracks
- Inheritance
-
NodeTracks
- Inherited Members
Methods
DecodeAsync(string, CancellationToken)
Decodes a base64 track through the server (with its metadata), Decode(string) skips the server call for tracks this library understands.
public Task<Track> DecodeAsync(string encodedTrack, CancellationToken cancellationToken = default)
Parameters
encodedTrackstringThe base64 track to decode.
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
Exceptions
- IncompatibleServerException
The server's /v4/info version is not supported.
DecodeManyAsync(IEnumerable<string>, CancellationToken)
Decodes base64 tracks, contacting the server.
public Task<IReadOnlyList<Track>> DecodeManyAsync(IEnumerable<string> encodedTracks, CancellationToken cancellationToken = default)
Parameters
encodedTracksIEnumerable<string>The base64 tracks to decode.
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- Task<IReadOnlyList<Track>>
The decoded tracks, in the order they were given.
Exceptions
- IncompatibleServerException
The server's /v4/info version is not supported.
EncodeAsync(TrackInfo, CancellationToken)
Encodes track information into a base64 track the node can play.
public Task<string> EncodeAsync(TrackInfo info, CancellationToken cancellationToken = default)
Parameters
infoTrackInfoThe track info to encode.
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
Remarks
NodeLink only.
Exceptions
- NotSupportedException
The node is not NodeLink.
- IncompatibleServerException
The server's /v4/info version is not supported.
EncodeManyAsync(IEnumerable<TrackInfo>, CancellationToken)
Encodes track information into base64 tracks the node can play.
public Task<IReadOnlyList<string>> EncodeManyAsync(IEnumerable<TrackInfo> infos, CancellationToken cancellationToken = default)
Parameters
infosIEnumerable<TrackInfo>The track infos to encode.
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- Task<IReadOnlyList<string>>
The encoded base64 tracks, in the order they were given.
Remarks
NodeLink only.
Exceptions
- NotSupportedException
The node is not NodeLink.
- IncompatibleServerException
The server's /v4/info version is not supported.
GetStreamUrlAsync(Track, int?, CancellationToken)
Resolves the direct stream URL of a track's audio.
public Task<TrackStreamUrl> GetStreamUrlAsync(Track track, int? itag = null, CancellationToken cancellationToken = default)
Parameters
trackTrackThe track to resolve.
itagint?The itag to resolve for, null lets the server pick.
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- Task<TrackStreamUrl>
The resolved stream URL and format.
Remarks
The server picks a default format when no itag is given. The resolved URL is
short-lived, re-resolve it instead of caching it.
Exceptions
- ArgumentNullException
trackis null.- ArgumentException
The track carries a null or empty encoded form.
- ArgumentOutOfRangeException
itagis negative.- RestException
The route is disabled on the server, or the track failed to resolve.
- NodeUnreachableException
The transport failed before an answer arrived.
- TimeoutException
The node's REST endpoint did not answer within its bound.
- NotSupportedException
The node is not NodeLink.
- IncompatibleServerException
The server's /v4/info version is not supported.
OpenAudioStreamAsync(Track, int, TimeSpan?, FilterChain?, LoadStreamFormat, CancellationToken)
Opens the decoded audio of a track as a readable stream, played through the node's audio pipeline with the given volume, start position and filter chain.
public Task<Stream> OpenAudioStreamAsync(Track track, int volume = 100, TimeSpan? position = null, FilterChain? filters = null, LoadStreamFormat format = LoadStreamFormat.Raw, CancellationToken cancellationToken = default)
Parameters
trackTrackThe track to stream.
volumeintThe playback volume, 0-1000, 100 is the neutral value.
positionTimeSpan?Where in the track the stream starts.
filtersFilterChainThe filter chain applied to the stream, null streams unfiltered.
formatLoadStreamFormatThe container format of the stream, raw PCM by default. Only Raw and Wav are valid, any other value is rejected before the first request.
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
Remarks
The caller owns the returned stream.
Exceptions
- ArgumentNullException
trackis null.- ArgumentOutOfRangeException
volumeis outside 0-1000,positionis negative, orformatis not Raw or Wav.- RestException
The route is disabled on the server, or the track failed to load.
- NodeUnreachableException
The transport failed before an answer arrived.
- TimeoutException
The node's REST endpoint did not answer within its bound.
- NotSupportedException
The node is not NodeLink, or the node is a NodeLink older than 3.10.0 and
formatis Wav.- IncompatibleServerException
The server's /v4/info version is not supported.