Fix playing of external audio files

QUrl::fromUserInput().isRelative() returns false for things like "sound.ogg"
because it converts it to http://sound.ogg

So we use the variant where we give it the document folder, this way if
the file exists returns the local file.

For full urls we get the full url with this second variant so all should
be good
This commit is contained in:
Albert Astals Cid 2023-08-04 00:21:02 +02:00
parent 22550bbc05
commit 0a3f4a78a3

View file

@ -162,13 +162,7 @@ bool AudioPlayerPrivate::play(const SoundInfo &si)
if (!url.isEmpty()) {
int newid = newId();
QObject::connect(data->m_mediaobject, &Phonon::MediaObject::finished, q, [this, newid]() { finished(newid); });
QUrl newurl;
if (QUrl::fromUserInput(url).isRelative()) {
newurl = m_currentDocument.adjusted(QUrl::RemoveFilename);
newurl.setPath(newurl.path() + url);
} else {
newurl = QUrl::fromLocalFile(url);
}
const QUrl newurl = QUrl::fromUserInput(url, m_currentDocument.adjusted(QUrl::RemoveFilename).toLocalFile());
data->m_mediaobject->setCurrentSource(newurl);
m_playing.insert(newid, data);
valid = true;