From 2c516d1148562041da3732241d8ecb8bed430c51 Mon Sep 17 00:00:00 2001 From: Arno Date: Mon, 6 Mar 2017 05:53:36 +0100 Subject: Fix display of length Stop the dance in setDuration. Get rid of the function and use TagLib::File::AudioProperties in play() to set it. --- playerwidget.cpp | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'playerwidget.cpp') diff --git a/playerwidget.cpp b/playerwidget.cpp index beec5c7..b9152d1 100644 --- a/playerwidget.cpp +++ b/playerwidget.cpp @@ -795,6 +795,14 @@ void PlayerWidget::play(const QString &fullPath){ mCurrentTE->append(QString("%1 %2").arg(tr("Genre:"), -20).arg(genre)); mCurrentTE->append(QString("%1 %2").arg(tr("Track:"), -20).arg(track, 3, 10, QChar('0'))); mCurrentTE->append(QString("%1 %2").arg(tr("Year:"), -20).arg(year, 4, 10)); + mCurrentTE->append(QString("%1 %2 kb/s").arg(tr("Bitrate:"), -20).arg(file.audioProperties()->bitrate(), 4, 10, QChar('0'))); + int length = file.audioProperties()->lengthInSeconds(); + mDurSecs = length; + mSongSlider->setMinimum(0); + mSongSlider->setMaximum(mDurSecs); + int minutes = mDurSecs / 60; + int seconds = mDurSecs % 60; + mCurrentTE->append(QString("%1 %2:%3").arg(tr("Length:"), -20).arg(minutes, 2, 10, QChar('0')).arg(seconds, 2, 10, QChar('0'))); QString msg = QString("File: %1").arg(fullPath); emit message(msg); mPlayer->play(); @@ -854,20 +862,6 @@ void PlayerWidget::setPosition(qint64 pos){ mPos->setText(posString); } -void PlayerWidget::setDuration(qint64 dur){ - mDurSecs = dur / 1000; - mSongSlider->setMinimum(0); - mSongSlider->setMaximum(mDurSecs); - int minutes = mDurSecs / 60; - int seconds = mDurSecs % 60; - QTextCursor cur = mCurrentTE->document()->find(QRegExp("^Length:")); - if(!cur.isNull()){ - cur.select(QTextCursor::BlockUnderCursor); - cur.removeSelectedText(); - } - mCurrentTE->append(QString("%1 %2:%3").arg(tr("Length:"), -20).arg(minutes, 2, 10, QChar('0')).arg(seconds, 2, 10, QChar('0'))); -} - void PlayerWidget::continuePlaying(QMediaPlayer::MediaStatus state){ if(state == QMediaPlayer::EndOfMedia){ next(); -- cgit v1.2.3-70-g09d2