Music Hub ..
A session-wide music playback service
 
Loading...
Searching...
No Matches
track.h
Go to the documentation of this file.
1/*
2 * Copyright © 2021-2022 UBports Foundation.
3 *
4 * Contact: Alberto Mardegan <mardy@users.sourceforge.net>
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License version 3,
8 * as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18#ifndef LOMIRI_MEDIAHUBSERVICE_TRACK_H
19#define LOMIRI_MEDIAHUBSERVICE_TRACK_H
20
21#include <QString>
22#include <QScopedPointer>
23#include <QUrl>
24#include <QVariantMap>
25
26namespace lomiri
27{
28namespace MediaHubService
29{
30
31class Track
32{
33public:
34 typedef QString Id;
35 typedef QVariantMap MetaDataType;
36
37 class MetaData: public MetaDataType
38 {
39 public:
40 using MetaDataType::MetaDataType;
41 static constexpr const char* TrackArtlUrlKey = "mpris:artUrl";
42 static constexpr const char* TrackLengthKey = "mpris:length";
43 static constexpr const char* TrackIdKey = "mpris:trackid";
44
45 template<typename Tag>
46 bool contains() const
47 {
48 return contains(Tag::name());
49 }
50
51 bool isSet(const QString &key) const
52 {
53 return !value(key).isNull();
54 }
55
56 void setAlbum(const QString &album);
57 void setArtist(const QString &artist);
58 void setTitle(const QString &title);
59 void setTrackId(const QString &id);
60 void setTrackLength(int64_t id);
61 void setArtUrl(const QUrl &url);
62 void setLastUsed(const QString &datetime);
63 QString album() const;
64 QString artist() const;
65 QString title() const;
66 QString trackId() const;
67 int64_t trackLength() const;
68 QUrl artUrl() const;
69 QString lastUsed() const;
70 };
71
72 Track(const Id& id);
73 Track(const Track&) = delete;
74 virtual ~Track();
75
77 bool operator==(const Track&) const;
78
79 const Id& id() const;
80 QUrl uri() const;
81
82private:
83 struct Private;
84 QScopedPointer<Private> d;
85};
86
87}
88}
89
90#endif // LOMIRI_MEDIAHUBSERVICE_TRACK_H
bool isSet(const QString &key) const
Definition track.h:51
static constexpr const char * TrackLengthKey
Definition track.h:42
void setLastUsed(const QString &datetime)
static constexpr const char * TrackIdKey
Definition track.h:43
void setArtist(const QString &artist)
static constexpr const char * TrackArtlUrlKey
Definition track.h:41
Track & operator=(const Track &)
Track(const Track &)=delete
bool operator==(const Track &) const