diff options
author | Arno <arno@disconnect.de> | 2017-03-06 05:53:36 +0100 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2017-03-06 05:53:36 +0100 |
commit | 2c516d1148562041da3732241d8ecb8bed430c51 (patch) | |
tree | 796941bf6d74eb012e994e65edac59aceebc7e70 /playerwidget.cpp | |
parent | 990beac98b2b407d255405aa374817f3c6fd1bba (diff) | |
download | BeetPlayer-2c516d1148562041da3732241d8ecb8bed430c51.tar.gz BeetPlayer-2c516d1148562041da3732241d8ecb8bed430c51.tar.bz2 BeetPlayer-2c516d1148562041da3732241d8ecb8bed430c51.zip |
Fix display of length
Stop the dance in setDuration. Get rid of the function and use
TagLib::File::AudioProperties in play() to set it.
Diffstat (limited to 'playerwidget.cpp')
-rw-r--r-- | playerwidget.cpp | 22 |
1 files changed, 8 insertions, 14 deletions
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(); |