-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspotifyapi.h
42 lines (34 loc) · 1.02 KB
/
spotifyapi.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef SPOTIFYAPI_H
#define SPOTIFYAPI_H
#include <QObject>
#include <QOAuth2AuthorizationCodeFlow>
#include <QTimer>
#include <QString>
class SpotifyAPI : public QObject
{
Q_OBJECT
public:
explicit SpotifyAPI(QObject *parent = nullptr);
void authenticate();
void getCurrentPlayingTrack();
private:
QOAuth2AuthorizationCodeFlow* m_oauth2;
QTimer* timer = new QTimer(this);
void setupOAuth2(const QString&);
void setupConnections();
void sendPlaybackCommand(const QUrl& commandUrl, bool wasAttemptingToPlay);
private slots:
void onGranted();
void onError(const QString & error1, const QString & error2, const QUrl & errorUrl);
public slots:
void onAuthenticated() {
timer->start(1000);
}
void togglePlayback();
signals:
void authenticated();
void trackInfoReceived(const QString &trackName, const QString &artistName, const QString &albumName);
void albumCoverReceived(const QString &albumCoverUrl);
void musicToggled(const bool on);
};
#endif // SPOTIFYAPI_H