mirror of
https://github.com/KDE/kasts.git
synced 2025-01-29 00:30:03 +01:00
Update enclosure duration if needed
If the duration that is mentioned in the enclosure doesn't correspond to the real duration then update to the real duration in the database.
This commit is contained in:
parent
e9d20ec569
commit
7a900b5921
@ -224,6 +224,12 @@ void AudioManager::setEntry(Entry* entry)
|
||||
Q_EMIT canGoNextChanged();
|
||||
d->m_isSeekable = true;
|
||||
Q_EMIT seekableChanged(true);
|
||||
qDebug() << "Duration" << d->m_player.duration()/1000 << d->m_entry->enclosure()->duration();
|
||||
// Finally, check if duration mentioned in enclosure corresponds to real duration
|
||||
if ((d->m_player.duration()/1000) != d->m_entry->enclosure()->duration()) {
|
||||
d->m_entry->enclosure()->setDuration(d->m_player.duration()/1000);
|
||||
qDebug() << "Correcting duration of" << d->m_entry->id() << "to" << d->m_player.duration()/1000;
|
||||
}
|
||||
} else {
|
||||
DataManager::instance().setLastPlayingEntry(QStringLiteral("none"));
|
||||
d->m_entry = nullptr;
|
||||
|
@ -176,10 +176,15 @@ Enclosure::Status Enclosure::status() const
|
||||
{
|
||||
return m_status;
|
||||
}
|
||||
|
||||
qint64 Enclosure::playPosition() const{
|
||||
return m_playposition;
|
||||
}
|
||||
|
||||
qint64 Enclosure::duration() const {
|
||||
return m_duration;
|
||||
}
|
||||
|
||||
void Enclosure::setPlayPosition(const qint64 &position)
|
||||
{
|
||||
m_playposition = position;
|
||||
@ -198,3 +203,18 @@ void Enclosure::setPlayPosition(const qint64 &position)
|
||||
m_playposition_dbsave = m_playposition;
|
||||
}
|
||||
}
|
||||
|
||||
void Enclosure::setDuration(const qint64 &duration)
|
||||
{
|
||||
m_duration = duration;
|
||||
Q_EMIT durationChanged();
|
||||
|
||||
// also save to database
|
||||
qDebug() << "updating entry duration" << duration << m_entry->title();
|
||||
QSqlQuery query;
|
||||
query.prepare(QStringLiteral("UPDATE Enclosures SET duration=:duration WHERE id=:id AND feed=:feed"));
|
||||
query.bindValue(QStringLiteral(":id"), m_entry->id());
|
||||
query.bindValue(QStringLiteral(":feed"), m_entry->feed()->url());
|
||||
query.bindValue(QStringLiteral(":duration"), m_duration);
|
||||
Database::instance().execute(query);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ class Enclosure : public QObject
|
||||
Q_PROPERTY(double downloadProgress MEMBER m_downloadProgress NOTIFY downloadProgressChanged)
|
||||
Q_PROPERTY(QString path READ path CONSTANT)
|
||||
Q_PROPERTY(qint64 playPosition READ playPosition WRITE setPlayPosition NOTIFY playPositionChanged)
|
||||
Q_PROPERTY(qint64 duration MEMBER m_duration CONSTANT)
|
||||
Q_PROPERTY(qint64 duration READ duration WRITE setDuration NOTIFY durationChanged)
|
||||
|
||||
public:
|
||||
Enclosure(Entry *entry);
|
||||
@ -46,13 +46,17 @@ public:
|
||||
QString path() const;
|
||||
Status status() const;
|
||||
qint64 playPosition() const;
|
||||
qint64 duration() const;
|
||||
|
||||
void setPlayPosition(const qint64 &position);
|
||||
void setDuration(const qint64 &duration);
|
||||
|
||||
Q_SIGNALS:
|
||||
void statusChanged();
|
||||
void downloadProgressChanged();
|
||||
void cancelDownload();
|
||||
void playPositionChanged();
|
||||
void durationChanged();
|
||||
|
||||
private:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user