Workaround "autoplay" issues with new MPV API (>=2.5, as on pmos/alpine edge)
This commit is contained in:
parent
5daba546a1
commit
346a757d6c
2 changed files with 19 additions and 3 deletions
|
|
@ -158,6 +158,10 @@ void MpvAudio::handleEvent(mpv_event *ev) {
|
|||
emit chapterMetadataChanged();
|
||||
|
||||
if( !m_loaded ) {
|
||||
#if MPV_CLIENT_API_VERSION >= MPV_MAKE_VERSION(2, 5)
|
||||
if( !m_autoplay )
|
||||
pause();
|
||||
#endif
|
||||
m_loaded = true;
|
||||
emit loadedChanged();
|
||||
}
|
||||
|
|
@ -346,13 +350,21 @@ void MpvAudio::load(const QUrl &url, bool autoplay) {
|
|||
return;
|
||||
}
|
||||
|
||||
QByteArray aps = autoplay ? QString("pause=no").toUtf8() : QString("pause=yes").toUtf8();
|
||||
#if MPV_CLIENT_API_VERSION >= MPV_MAKE_VERSION(2, 5)
|
||||
m_autoplay = autoplay;
|
||||
const char *fparm = nullptr;
|
||||
#else
|
||||
QByteArray aps = QString("pause=yes").toUtf8();
|
||||
const char *fparm = autoplay ? nullptr : aps.constData();
|
||||
#endif
|
||||
|
||||
QByteArray u8 = s.toUtf8();
|
||||
const char *cmd[] = { "loadfile", u8.constData(), "replace", aps.constData(), nullptr };
|
||||
const char *cmd[] = { "loadfile", u8.constData(), "replace", fparm, nullptr };
|
||||
int r = mpv_command(m_mpv, cmd);
|
||||
if( r < 0 )
|
||||
if( r < 0 ) {
|
||||
emit errorOccurred(QStringLiteral("MpvAudio::load failed: %1").arg(QString::fromUtf8(mpv_error_string(r))));
|
||||
return;
|
||||
}
|
||||
|
||||
//setPaused(false);
|
||||
m_source = url;
|
||||
|
|
|
|||
|
|
@ -150,6 +150,10 @@ private:
|
|||
QVariantList m_chapters;
|
||||
int m_currentChapter = -1;
|
||||
QVariantMap m_chapterMetadata;
|
||||
|
||||
#if MPV_CLIENT_API_VERSION >= MPV_MAKE_VERSION(2, 5)
|
||||
bool m_autoplay;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // MPVAUDIO_H
|
||||
|
|
|
|||
Loading…
Reference in a new issue