-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaylist.h
75 lines (60 loc) · 1.41 KB
/
playlist.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#ifndef PLAYLIST_H
#define PLAYLIST_H
#include <QObject>
#include <functional>
#include <QDir>
#include <QUrl>
#include <QTimer>
#include <QVector>
#include <QtNetwork/QNetworkAccessManager>
#include <QJsonObject>
struct Entry;
class Playlist : public QObject
{
Q_OBJECT
public:
enum class Type {
IMAGE, VIDEO
};
Q_ENUM(Type)
explicit Playlist(QObject *parent = 0);
~Playlist();
const Entry& next();
void macAddress(const QString& address);
void url(const QString& url);
signals:
void playlistAvailable();
public slots:
void refreshMetadata();
void checkForCachedMetadata();
private:
QString _sequenceId;
qint64 _published = -1;
QTimer _metadataRefreshTimer;
QDir _cachePath;
QDir _entryPath;
QNetworkAccessManager _nam;
QVector<Entry> _entries;
QVector<Entry> _refreshEntries;
QVector<Entry>::Iterator _refreshIterator;
QVector<Entry>::Iterator _playbackIterator;
QString _mac;
QString _url;
void cleanupStaleEntries();
void downloadEntries();
void parseMetadata();
void parseMetadataEntries(QJsonArray entries);
QJsonObject openJsonFile(QFile& sourceFile);
private slots:
void onRefreshFinished();
void onFetchEntryFinished();
};
struct Entry {
QString fileId;
QString filePath;
Playlist::Type type;
int durationMillis;
QUrl url;
bool loaded = false;
};
#endif // PLAYLIST_H