Class RestClient
- Namespace
- XeroxDev.YTMDesktop.Companion.Clients
- Assembly
- XeroxDev.YTMDesktop.Companion.dll
A REST client to communicate with the companion servers REST API
public class RestClient : IGenericClient
- Inheritance
-
RestClient
- Implements
- Inherited Members
Constructors
RestClient(ConnectorSettings)
A REST client to communicate with the companion servers REST API
public RestClient(ConnectorSettings settings)
Parameters
settings
ConnectorSettingsThe settings to use for the client
Properties
Settings
The settings to use for the client
public ConnectorSettings Settings { get; set; }
Property Value
Methods
ChangeVideo(string, string, string)
Change the video. Either videoId or playlistId or both have to be set. You can also set an url instead. Url is prioritized over videoId and playlistId
public Task ChangeVideo(string videoId = null, string playlistId = null, string url = null)
Parameters
videoId
stringThe video id from the video to play
playlistId
stringThe playlist id from the playlist to play
url
stringThe url to play
Returns
Exceptions
- ArgumentNullException
Thrown when videoId and playlistId are null
- ApiException
Thrown when an error occurred while sending the request. Error is either from the server or from the client
GetAuthCode()
Requests a code to exchange for an auth token
public Task<string> GetAuthCode()
Returns
Exceptions
- ApiException
Thrown when an error occurred while sending the request. Error is either from the server or from the client
GetAuthToken(string)
Get the authentication token that is required to access the API.
You should save this token safely and set it either:
- in the settings
- use the SetAuthToken(string) method in this class
- use the SetAuthToken(string) method in the CompanionConnector class
public Task<string> GetAuthToken(string code)
Parameters
code
stringThe code you got from the GetAuthCode() method
Returns
Exceptions
- ApiException
Thrown when an error occurred while sending the request. Error is either from the server or from the client
GetMetadata()
Get the metadata from the API
public Task<MetadataOutput> GetMetadata()
Returns
- Task<MetadataOutput>
The metadata from the API
Exceptions
- ApiException
Thrown when an error occurred while sending the request. Error is either from the server or from the client
GetPlaylists()
Get the playlists from the API
public Task<PlaylistOutput[]> GetPlaylists()
Returns
- Task<PlaylistOutput[]>
The playlists from the API
Exceptions
- ApiException
Thrown when an error occurred while sending the request. Error is either from the server or from the client
GetState()
Get the state from the API
public Task<StateOutput> GetState()
Returns
- Task<StateOutput>
The state from the API
Exceptions
- ApiException
Thrown when an error occurred while sending the request. Error is either from the server or from the client
Mute()
Mute the volume
public Task Mute()
Returns
Exceptions
- ApiException
Thrown when an error occurred while sending the request. Error is either from the server or from the client
Next()
Skip to the next song
public Task Next()
Returns
Exceptions
- ApiException
Thrown when an error occurred while sending the request. Error is either from the server or from the client
Pause()
Pause the current song
public Task Pause()
Returns
Exceptions
- ApiException
Thrown when an error occurred while sending the request. Error is either from the server or from the client
Play()
Play the current song
public Task Play()
Returns
Exceptions
- ApiException
Thrown when an error occurred while sending the request. Error is either from the server or from the client
PlayPause()
Play or pause the current song
public Task PlayPause()
Returns
Exceptions
- ApiException
Thrown when an error occurred while sending the request. Error is either from the server or from the client
PlayQueueIndex(int)
Play a song from the queue
public Task PlayQueueIndex(int index)
Parameters
index
int
Returns
Exceptions
- ApiException
Thrown when an error occurred while sending the request. Error is either from the server or from the client
Previous()
Skip to the previous song
public Task Previous()
Returns
Exceptions
- ApiException
Thrown when an error occurred while sending the request. Error is either from the server or from the client
SeekTo(int)
Seek to a specific time in the song
public Task SeekTo(int time)
Parameters
time
intThe time to seek to
Returns
Exceptions
- ApiException
Thrown when an error occurred while sending the request. Error is either from the server or from the client
SetAuthToken(string)
Set the authentication token, so it can be used for further requests.
We recommend to use the SetAuthToken(string) method in the
CompanionConnector class instead of this method because it also reconnects the socket client if the token changed.
public void SetAuthToken(string token)
Parameters
token
stringThe token to set
SetRepeatMode(ERepeatMode)
Set the repeat mode
public Task SetRepeatMode(ERepeatMode mode)
Parameters
mode
ERepeatModeThe mode to set
Returns
Exceptions
- ApiException
Thrown when an error occurred while sending the request. Error is either from the server or from the client
SetVolume(int)
Set the volume
public Task SetVolume(int volume)
Parameters
volume
intThe volume to set
Returns
Exceptions
- ApiException
Thrown when an error occurred while sending the request. Error is either from the server or from the client
Shuffle()
Shuffle the queue
public Task Shuffle()
Returns
Exceptions
- ApiException
Thrown when an error occurred while sending the request. Error is either from the server or from the client
ToggleDislike()
Toggle dislike the current song
public Task ToggleDislike()
Returns
Exceptions
- ApiException
Thrown when an error occurred while sending the request. Error is either from the server or from the client
ToggleLike()
Toggle like the current song
public Task ToggleLike()
Returns
Exceptions
- ApiException
Thrown when an error occurred while sending the request. Error is either from the server or from the client
Unmute()
Unmute the volume
public Task Unmute()
Returns
Exceptions
- ApiException
Thrown when an error occurred while sending the request. Error is either from the server or from the client
VolumeDown()
Decrease the volume
public Task VolumeDown()
Returns
Exceptions
- ApiException
Thrown when an error occurred while sending the request. Error is either from the server or from the client
VolumeUp()
Increase the volume
public Task VolumeUp()
Returns
Exceptions
- ApiException
Thrown when an error occurred while sending the request. Error is either from the server or from the client