return UNKNOWN;
}
-void QPlaylistFileParser::start(const QUrl& url, bool utf8)
+void QPlaylistFileParser::start(const QNetworkRequest& request, bool utf8)
{
Q_D(QPlaylistFileParser);
stop();
d->m_type = UNKNOWN;
d->m_utf8 = utf8;
- d->m_root = url;
+ d->m_root = request.url();
- if (url.isLocalFile() && !QFile::exists(url.toLocalFile())) {
- emit error(NetworkError, QString(tr("%1 does not exist")).arg(url.toString()));
+ if (d->m_root.isLocalFile() && !QFile::exists(d->m_root.toLocalFile())) {
+ emit error(NetworkError, QString(tr("%1 does not exist")).arg(d->m_root.toString()));
return;
}
- d->m_source = d->m_mgr.get(QNetworkRequest(url));
+ d->m_source = d->m_mgr.get(request);
connect(d->m_source, SIGNAL(readyRead()), this, SLOT(_q_handleData()));
connect(d->m_source, SIGNAL(finished()), this, SLOT(_q_handleData()));
static FileType findPlaylistType(const QString& uri, const QString& mime, const void *data, quint32 size);
- void start(const QUrl& url, bool utf8 = false);
+ void start(const QNetworkRequest &request, bool utf8 = false);
void stop();
Q_SIGNALS:
{
Q_DECLARE_NON_CONST_PUBLIC(QMediaNetworkPlaylistProvider)
public:
- bool load(const QUrl &location);
+ bool load(const QNetworkRequest &request);
QPlaylistFileParser parser;
QList<QMediaContent> resources;
QMediaNetworkPlaylistProvider *q_ptr;
};
-bool QMediaNetworkPlaylistProviderPrivate::load(const QUrl &location)
+bool QMediaNetworkPlaylistProviderPrivate::load(const QNetworkRequest &request)
{
parser.stop();
- parser.start(location, false);
+ parser.start(request, false);
return true;
}
return false;
}
-bool QMediaNetworkPlaylistProvider::load(const QUrl &location, const char *format)
+bool QMediaNetworkPlaylistProvider::load(const QNetworkRequest &request, const char *format)
{
Q_UNUSED(format);
- return d_func()->load(location);
+ return d_func()->load(request);
}
int QMediaNetworkPlaylistProvider::mediaCount() const
QMediaNetworkPlaylistProvider(QObject *parent=0);
virtual ~QMediaNetworkPlaylistProvider();
- virtual bool load(const QUrl &location, const char *format = 0);
+ virtual bool load(const QNetworkRequest &request, const char *format = 0);
virtual int mediaCount() const;
virtual QMediaContent media(int pos) const;
pendingPlaylist = QMediaContent(new QMediaPlaylist, q->currentMedia().canonicalUrl(), true);
QObject::connect(pendingPlaylist.playlist(), SIGNAL(loaded()), q, SLOT(_q_handlePlaylistLoaded()));
QObject::connect(pendingPlaylist.playlist(), SIGNAL(loadFailed()), q, SLOT(_q_handlePlaylistLoadFailed()));
- pendingPlaylist.playlist()->load(pendingPlaylist.canonicalUrl());
+ pendingPlaylist.playlist()->load(pendingPlaylist.canonicalRequest());
} else if (playlist) {
playlist->next();
}
}
/*!
- Load playlist from \a location. If \a format is specified, it is used,
- otherwise format is guessed from location name and data.
+ Load playlist using network \a request. If \a format is specified, it is used,
+ otherwise format is guessed from playlist name and data.
New items are appended to playlist.
QMediaPlaylist::loaded() signal is emitted if playlist was loaded successfully,
otherwise the playlist emits loadFailed().
*/
-void QMediaPlaylist::load(const QUrl &location, const char *format)
+void QMediaPlaylist::load(const QNetworkRequest &request, const char *format)
{
Q_D(QMediaPlaylist);
d->error = NoError;
d->errorString.clear();
- if (d->playlist()->load(location,format))
+ if (d->playlist()->load(request,format))
return;
if (isReadOnly()) {
foreach (QString const& key, playlistIOLoader()->keys()) {
QMediaPlaylistIOInterface* plugin = qobject_cast<QMediaPlaylistIOInterface*>(playlistIOLoader()->instance(key));
- if (plugin && plugin->canRead(location,format)) {
- QMediaPlaylistReader *reader = plugin->createReader(location,QByteArray(format));
+ if (plugin && plugin->canRead(request.url(), format)) {
+ QMediaPlaylistReader *reader = plugin->createReader(request.url(), QByteArray(format));
if (reader && d->readItems(reader)) {
delete reader;
emit loaded();
}
/*!
+ Load playlist from \a location. If \a format is specified, it is used,
+ otherwise format is guessed from location name and data.
+
+ New items are appended to playlist.
+
+ QMediaPlaylist::loaded() signal is emitted if playlist was loaded successfully,
+ otherwise the playlist emits loadFailed().
+*/
+
+void QMediaPlaylist::load(const QUrl &location, const char *format)
+{
+ load(QNetworkRequest(location), format);
+}
+
+/*!
Load playlist from QIODevice \a device. If \a format is specified, it is used,
otherwise format is guessed from device data.
bool removeMedia(int start, int end);
bool clear();
+ void load(const QNetworkRequest &request, const char *format = 0);
void load(const QUrl &location, const char *format = 0);
void load(QIODevice * device, const char *format = 0);
/*!
- Loads a playlist from from a URL \a location. If no playlist \a format is specified the loader
+ Loads a playlist using network \a request. If no playlist \a format is specified the loader
will inspect the URL or probe the headers to guess the format.
New items are appended to playlist.
Returns true if the provider supports the format and loading from the locations URL protocol,
otherwise this will return false.
*/
-bool QMediaPlaylistProvider::load(const QUrl &location, const char *format)
+bool QMediaPlaylistProvider::load(const QNetworkRequest &request, const char *format)
{
- Q_UNUSED(location);
+ Q_UNUSED(request);
Q_UNUSED(format);
return false;
}
QMediaPlaylistProvider(QObject *parent=0);
virtual ~QMediaPlaylistProvider();
- virtual bool load(const QUrl &location, const char *format = 0);
+ virtual bool load(const QNetworkRequest &request, const char *format = 0);
virtual bool load(QIODevice * device, const char *format = 0);
virtual bool save(const QUrl &location, const char *format = 0);
virtual bool save(QIODevice * device, const char *format);
//ensure #2 suffix is not stripped from path
testFileName = QFINDTESTDATA("testdata/testfile2#suffix");
QCOMPARE(playlist.media(6).canonicalUrl(), QUrl::fromLocalFile(testFileName));
+ // check ability to load from QNetworkRequest
+ QSignalSpy loadSpy(&playlist, SIGNAL(loaded()));
+ QSignalSpy loadFailedSpy(&playlist, SIGNAL(loadFailed()));
+ playlist.load(QNetworkRequest(QUrl::fromLocalFile(QFINDTESTDATA("testdata/test.m3u"))));
+ QTRY_VERIFY(!loadSpy.isEmpty());
+ QVERIFY(loadFailedSpy.isEmpty());
}
void tst_QMediaPlaylist::playbackMode_data()