mirror of
https://invent.kde.org/graphics/okular
synced 2024-09-29 20:54:45 +00:00
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:
parent
22550bbc05
commit
0a3f4a78a3
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue