2023-12-17 03:29:08 -08:00
|
|
|
#pragma once
|
|
|
|
|
2023-12-17 15:00:08 -08:00
|
|
|
#include "EHS.h"
|
|
|
|
#include "Str.h"
|
|
|
|
#include "Array.h"
|
2023-12-17 15:56:13 -08:00
|
|
|
#include "io/socket/SSL.h"
|
2023-12-17 03:29:08 -08:00
|
|
|
|
2023-12-17 15:56:13 -08:00
|
|
|
namespace ehs
|
2023-12-17 03:29:08 -08:00
|
|
|
{
|
|
|
|
enum class SpotifyState
|
|
|
|
{
|
|
|
|
TRACK,
|
|
|
|
CONTEXT,
|
|
|
|
OFF
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Track
|
|
|
|
{
|
|
|
|
Array<Str_8> artists;
|
|
|
|
Str_8 name;
|
|
|
|
Str_8 id;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Spotify
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
SSL client;
|
|
|
|
Str_8 clientId;
|
|
|
|
Str_8 secret;
|
|
|
|
Str_8 redURI;
|
|
|
|
Array<Str_8> scopes;
|
|
|
|
bool forceVerify;
|
|
|
|
Str_8 token;
|
|
|
|
Str_8 rToken;
|
|
|
|
|
|
|
|
public:
|
|
|
|
static const Str_8 trackUriPrefix;
|
|
|
|
|
|
|
|
virtual ~Spotify();
|
|
|
|
|
|
|
|
Spotify();
|
|
|
|
|
|
|
|
Spotify(const Str_8& clientId, const Str_8& secret, const Str_8& redURI, const Array<Str_8>& scopes, const bool forceVerify);
|
|
|
|
|
|
|
|
bool Authorize();
|
|
|
|
|
|
|
|
/// Sets the volume for a device.
|
|
|
|
/// @param [in] level The percentage to set the volume to.
|
|
|
|
/// @returns The response code.
|
|
|
|
UInt_32 SetVolume(const UInt_8 level);
|
|
|
|
|
|
|
|
/// Resume playback for a device.
|
|
|
|
/// @returns The response code.
|
|
|
|
UInt_32 Play();
|
|
|
|
|
|
|
|
/// Pauses playback for a device.
|
|
|
|
/// @returns The response code.
|
|
|
|
UInt_32 Pause();
|
|
|
|
|
|
|
|
/// Repeats playback for a device.
|
|
|
|
/// @param [in] status The status to set it to.
|
|
|
|
/// @returns The response code.
|
|
|
|
UInt_32 SetRepeat(const SpotifyState state);
|
|
|
|
|
|
|
|
/// Shuffles playback for a device.
|
|
|
|
/// @param [in] state The state to set shuffle to.
|
|
|
|
/// @returns The response code.
|
|
|
|
UInt_32 SetShuffle(const bool state);
|
|
|
|
|
|
|
|
UInt_32 SearchTrack(Vector<Str_8>& artists, Str_8& id, Str_8& name);
|
|
|
|
|
|
|
|
UInt_32 GetPlayingTrack(Vector<Str_8>& artists, Str_8& id, Str_8& name);
|
|
|
|
|
|
|
|
UInt_32 GetQueue(Array<Track>& tracks);
|
|
|
|
|
|
|
|
/// Adds a track to the queue for a device.
|
|
|
|
/// @param [in] uri The track id to add.
|
|
|
|
/// @returns The response code.
|
|
|
|
UInt_32 QueueTrack(const Str_8& id);
|
|
|
|
|
|
|
|
UInt_32 AddTracks(const Str_8& playlistId, const Array<Str_8>& trackIds, const UInt_32 pos = 0);
|
|
|
|
|
|
|
|
UInt_32 AddTrack(const Str_8& playlistId, const Str_8& trackId, const UInt_32 pos = 0);
|
|
|
|
|
|
|
|
/// Skips to the next track.
|
|
|
|
/// @returns The response code.
|
|
|
|
UInt_32 Skip();
|
|
|
|
|
|
|
|
/// Skips to the previous track.
|
|
|
|
/// @returns The response code.
|
|
|
|
UInt_32 Previous();
|
|
|
|
|
|
|
|
/// Seeks to a position of the currently playing track in milliseconds.
|
|
|
|
/// @param [in] pos The position in milliseconds to seek to.
|
|
|
|
/// @returns The response code.
|
|
|
|
UInt_32 Seek(const UInt_32 pos);
|
|
|
|
|
|
|
|
Str_8 GetClientId() const;
|
|
|
|
|
|
|
|
Str_8 GetSecret() const;
|
|
|
|
|
|
|
|
Str_8 GetRedURI() const;
|
|
|
|
|
|
|
|
bool IsVerificationForced() const;
|
|
|
|
|
|
|
|
bool IsActive() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void StartConnection();
|
|
|
|
|
|
|
|
bool ReAuthorize();
|
|
|
|
};
|
|
|
|
}
|