1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#include "qmediaplaylistprovider_p.h"
41
42#include <QtCore/qurl.h>
43
44QT_BEGIN_NAMESPACE
45
46/*!
47 \class QMediaPlaylistProvider
48 \internal
49
50 \brief The QMediaPlaylistProvider class provides an abstract list of media.
51 \inmodule QtMultimedia
52
53 \ingroup multimedia
54 \ingroup multimedia_playback
55
56 \sa QMediaPlaylist
57*/
58
59/*!
60 Constructs a playlist provider with the given \a parent.
61*/
62QMediaPlaylistProvider::QMediaPlaylistProvider(QObject *parent)
63 :QObject(parent), d_ptr(new QMediaPlaylistProviderPrivate)
64{
65}
66
67/*!
68 \internal
69*/
70QMediaPlaylistProvider::QMediaPlaylistProvider(QMediaPlaylistProviderPrivate &dd, QObject *parent)
71 :QObject(parent), d_ptr(&dd)
72{
73}
74
75/*!
76 Destroys a playlist provider.
77*/
78QMediaPlaylistProvider::~QMediaPlaylistProvider()
79{
80 delete d_ptr;
81}
82
83/*!
84 \fn QMediaPlaylistProvider::mediaCount() const;
85
86 Returns the size of playlist.
87*/
88
89/*!
90 \fn QMediaPlaylistProvider::media(int index) const;
91
92 Returns the media at \a index in the playlist.
93
94 If the index is invalid this will return a null media content.
95*/
96
97
98/*!
99 Loads a playlist using network \a request. If no playlist \a format is specified the loader
100 will inspect the URL or probe the headers to guess the format.
101
102 New items are appended to playlist.
103
104 Returns true if the provider supports the format and loading from the locations URL protocol,
105 otherwise this will return false.
106*/
107bool QMediaPlaylistProvider::load(const QNetworkRequest &request, const char *format)
108{
109 Q_UNUSED(request);
110 Q_UNUSED(format);
111 return false;
112}
113
114/*!
115 Loads a playlist from from an I/O \a device. If no playlist \a format is specified the loader
116 will probe the headers to guess the format.
117
118 New items are appended to playlist.
119
120 Returns true if the provider supports the format and loading from an I/O device, otherwise this
121 will return false.
122*/
123bool QMediaPlaylistProvider::load(QIODevice * device, const char *format)
124{
125 Q_UNUSED(device);
126 Q_UNUSED(format);
127 return false;
128}
129
130/*!
131 Saves the contents of a playlist to a URL \a location. If no playlist \a format is specified
132 the writer will inspect the URL to guess the format.
133
134 Returns true if the playlist was saved successfully; and false otherwise.
135 */
136bool QMediaPlaylistProvider::save(const QUrl &location, const char *format)
137{
138 Q_UNUSED(location);
139 Q_UNUSED(format);
140 return false;
141}
142
143/*!
144 Saves the contents of a playlist to an I/O \a device in the specified \a format.
145
146 Returns true if the playlist was saved successfully; and false otherwise.
147*/
148bool QMediaPlaylistProvider::save(QIODevice * device, const char *format)
149{
150 Q_UNUSED(device);
151 Q_UNUSED(format);
152 return false;
153}
154
155/*!
156 Returns true if a playlist is read-only; otherwise returns false.
157*/
158bool QMediaPlaylistProvider::isReadOnly() const
159{
160 return true;
161}
162
163/*!
164 Append \a media to a playlist.
165
166 Returns true if the media was appended; and false otherwise.
167*/
168bool QMediaPlaylistProvider::addMedia(const QMediaContent &media)
169{
170 Q_UNUSED(media);
171 return false;
172}
173
174/*!
175 Append multiple media \a items to a playlist.
176
177 Returns true if the media items were appended; and false otherwise.
178*/
179bool QMediaPlaylistProvider::addMedia(const QList<QMediaContent> &items)
180{
181 for (const QMediaContent &item : items) {
182 if (!addMedia(media: item))
183 return false;
184 }
185
186 return true;
187}
188
189/*!
190 Inserts \a media into a playlist at \a position.
191
192 Returns true if the media was inserted; and false otherwise.
193*/
194bool QMediaPlaylistProvider::insertMedia(int position, const QMediaContent &media)
195{
196 Q_UNUSED(position);
197 Q_UNUSED(media);
198 return false;
199}
200
201/*!
202 Inserts multiple media \a items into a playlist at \a position.
203
204 Returns true if the media \a items were inserted; and false otherwise.
205*/
206bool QMediaPlaylistProvider::insertMedia(int position, const QList<QMediaContent> &items)
207{
208 for (int i=0; i<items.count(); i++) {
209 if (!insertMedia(position: position+i,media: items.at(i)))
210 return false;
211 }
212
213 return true;
214}
215
216/*!
217 Move the media from position \a from to position \a to.
218
219 Returns true if the operation is successful, otherwise false.
220
221 \since 5.7
222*/
223bool QMediaPlaylistProvider::moveMedia(int from, int to)
224{
225 Q_UNUSED(from);
226 Q_UNUSED(to);
227
228 return false;
229}
230
231/*!
232 Removes the media at \a position from a playlist.
233
234 Returns true if the media was removed; and false otherwise.
235*/
236bool QMediaPlaylistProvider::removeMedia(int position)
237{
238 Q_UNUSED(position);
239 return false;
240}
241
242/*!
243 Removes the media between the given \a start and \a end positions from a playlist.
244
245 Returns true if the media was removed; and false otherwise.
246 */
247bool QMediaPlaylistProvider::removeMedia(int start, int end)
248{
249 for (int pos=end; pos>=start; pos--) {
250 if (!removeMedia(position: pos))
251 return false;
252 }
253
254 return true;
255}
256
257/*!
258 Removes all media from a playlist.
259
260 Returns true if the media was removed; and false otherwise.
261*/
262bool QMediaPlaylistProvider::clear()
263{
264 return removeMedia(start: 0, end: mediaCount()-1);
265}
266
267/*!
268 Shuffles the contents of a playlist.
269*/
270void QMediaPlaylistProvider::shuffle()
271{
272}
273
274/*!
275 \fn void QMediaPlaylistProvider::mediaAboutToBeInserted(int start, int end);
276
277 Signals that new media is about to be inserted into a playlist between the \a start and \a end
278 positions.
279*/
280
281/*!
282 \fn void QMediaPlaylistProvider::mediaInserted(int start, int end);
283
284 Signals that new media has been inserted into a playlist between the \a start and \a end
285 positions.
286*/
287
288/*!
289 \fn void QMediaPlaylistProvider::mediaAboutToBeRemoved(int start, int end);
290
291 Signals that media is about to be removed from a playlist between the \a start and \a end
292 positions.
293*/
294
295/*!
296 \fn void QMediaPlaylistProvider::mediaRemoved(int start, int end);
297
298 Signals that media has been removed from a playlist between the \a start and \a end positions.
299*/
300
301/*!
302 \fn void QMediaPlaylistProvider::mediaChanged(int start, int end);
303
304 Signals that media in playlist between the \a start and \a end positions inclusive has changed.
305*/
306
307/*!
308 \fn void QMediaPlaylistProvider::loaded()
309
310 Signals that a load() finished successfully.
311*/
312
313/*!
314 \fn void QMediaPlaylistProvider::loadFailed(QMediaPlaylist::Error error, const QString& errorMessage)
315
316 Signals that a load failed() due to an \a error. The \a errorMessage provides more information.
317*/
318
319QT_END_NAMESPACE
320
321#include "moc_qmediaplaylistprovider_p.cpp"
322

source code of qtmultimedia/src/multimedia/playback/qmediaplaylistprovider.cpp