44
// The URL returned by Url() isn't the actual URL of the music - the
45
// item needs to do something special before it can get an actual URL.
46
// Causes StartLoading() to get called when the user wants to play.
47
SpecialPlayBehaviour = 0x01,
49
// This item might be able to provide another track after one finishes, for
50
// example in a radio stream. Causes LoadNext() to get called when the
51
// next URL is required.
52
ContainsMultipleTracks = 0x02,
54
45
// Disables the "pause" action.
57
48
// Enables the last.fm "ban" action.
58
LastFMControls = 0x08,
49
LastFMControls = 0x02,
51
// Disables the seek slider.
60
54
Q_DECLARE_FLAGS(Options, Option);
62
// Returned by StartLoading() and LoadNext(), indicates what the player
63
// should do when it wants to load a playlist item that is marked
64
// SpecialPlayBehaviour or ContainsMultipleTracks.
65
struct SpecialLoadResult {
67
// There wasn't a track available, and the player should move on to the
68
// next playlist item.
71
// There might be another track available, something will call the
72
// player's HandleSpecialLoad() slot later with the same original_url.
73
WillLoadAsynchronously,
75
// There was a track available. Its url is in media_url.
79
SpecialLoadResult(Type type = NoMoreTracks,
80
const QUrl& original_url = QUrl(),
81
const QUrl& media_url = QUrl());
85
// The url that the playlist items has in Url().
86
// Might be something unplayable like lastfm://...
89
// The actual url to something that gstreamer can play.
93
56
virtual QString type() const { return type_; }
95
58
virtual Options options() const { return Default; }
60
virtual QList<QAction*> actions() { return QList<QAction*>(); }
97
62
virtual bool InitFromQuery(const SqlRow& query) = 0;
98
63
void BindToQuery(QSqlQuery* query) const;
99
64
virtual void Reload() {}
102
67
virtual Song Metadata() const = 0;
103
68
virtual QUrl Url() const = 0;
105
// Called by the Player if SpecialPlayBehaviour is set - gives the playlist
106
// item a chance to do something clever to get a playable track.
107
virtual SpecialLoadResult StartLoading() { return SpecialLoadResult(); }
109
// Called by the player if ContainsMultipleTracks is set - gives the playlist
110
// item a chance to get another track to play.
111
virtual SpecialLoadResult LoadNext() { return SpecialLoadResult(); }
113
70
void SetTemporaryMetadata(const Song& metadata);
114
71
void ClearTemporaryMetadata();
115
72
bool HasTemporaryMetadata() const { return temp_metadata_.is_valid(); }
131
88
// Convenience function to find out whether this item is from the local
132
89
// library, as opposed to a device, a file on disk, or a stream.
133
90
// Remember that even if this returns true, the library item might be
134
// invalid so you might want to check that it's id is not equal to -1
91
// invalid so you might want to check that its id is not equal to -1
135
92
// before actually using it.
136
93
virtual bool IsLocalLibraryItem() const { return false; }
139
96
enum DatabaseColumn {
98
Column_InternetService,
151
101
virtual QVariant DatabaseValue(DatabaseColumn) const {
152
102
return QVariant(QVariant::String); }
103
virtual Song DatabaseSongMetadata() const { return Song(); }
161
112
typedef boost::shared_ptr<PlaylistItem> PlaylistItemPtr;
162
113
typedef QList<PlaylistItemPtr> PlaylistItemList;
164
Q_DECLARE_OPERATORS_FOR_FLAGS(PlaylistItem::Options);
115
Q_DECLARE_METATYPE(PlaylistItemPtr)
116
Q_DECLARE_METATYPE(QList<PlaylistItemPtr>)
117
Q_DECLARE_OPERATORS_FOR_FLAGS(PlaylistItem::Options)
166
119
#endif // PLAYLISTITEM_H