#pragma once #include "EHS.h" #include "Str.h" #include "Array.h" #include "IO/Socket/SSL.h" namespace lwe { enum class SpotifyState { TRACK, CONTEXT, OFF }; struct Track { Array artists; Str_8 name; Str_8 id; }; class Spotify { private: SSL client; Str_8 clientId; Str_8 secret; Str_8 redURI; Array 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& 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& artists, Str_8& id, Str_8& name); UInt_32 GetPlayingTrack(Vector& artists, Str_8& id, Str_8& name); UInt_32 GetQueue(Array& 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& 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(); }; }