Load pls file with QMediaPlaylist
Hi there,
I would like to load a pls file into my QMediaPlayer using QMediaPlaylist. First of all is pls supported? (I think so because I found a bug report but I am not sure)
This is my code: (source is correct. Because if the source file is a m3u it works)
Code:
AudioPlayer
::AudioPlayer(QObject *parent
) : playlist = new QMediaPlaylist;
player = new QMediaPlayer;
}
void AudioPlayer
::setSource(const QString &source
){ qDebug() << "Loading Playlist" << source;
playlist->load(source);
if(playlist->error())
qDebug() << playlist->errorString();
else
qDebug() << "Playlist loaded";
playlist->setCurrentIndex(1);
player->setPlaylist(playlist);
}
But I get the error that I provided an empty file. Can someone tell me what the proper way is to load a pls file?
Thanks!
Re: Load pls file with QMediaPlaylist
You need to pass a valid QNetworkRequest, QUrl or QIODevice* to load() for your playlist. You are currently passing a string and relying on the QUrl conversion constructor's default behaviour to come up with a good URL.
QMediaPlaylist contains a parser for PLS files so that should not be the problem.