From 1bd1b2bbcbe33f54c8dfdccdf94b2f862374e1dc Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Thu, 23 Jan 2020 17:57:50 -0500 Subject: Audio progress, flac support, about changed --- about.cpp | 6 ++++ about.ui | 2 +- player.cpp | 29 +++++++++++++++---- player.h | 6 ++++ player.ui | 94 +++++++++++++++++++++++++++++++------------------------------- 5 files changed, 84 insertions(+), 53 deletions(-) diff --git a/about.cpp b/about.cpp index 5bea58a..e3fde67 100644 --- a/about.cpp +++ b/about.cpp @@ -6,6 +6,12 @@ About::About(QWidget *parent) : ui(new Ui::About) { ui->setupUi(this); + + ui->label_3->setTextFormat(Qt::RichText); + + ui->label_3->setTextInteractionFlags(Qt::TextBrowserInteraction); + + ui->label_3->setOpenExternalLinks(true); } About::~About() diff --git a/about.ui b/about.ui index e8751e5..ebe6256 100644 --- a/about.ui +++ b/about.ui @@ -78,7 +78,7 @@ - Website: https://alee-productions.xyz + <html><head/><body><p><a href="https://alee-productions.xyz"><span style=" text-decoration: underline; color:#007af4;">Website</span></a></p></body></html> Qt::AlignCenter diff --git a/player.cpp b/player.cpp index e618afc..69fdd8a 100644 --- a/player.cpp +++ b/player.cpp @@ -6,13 +6,11 @@ #include "ui_player.h" #include "about.h" - - void Player::mFileDialog() { QString mFile; QMessageBox msgbox; - mFile = QFileDialog::getOpenFileName(this, "Open any audio file", QDir::homePath(), tr("Audio Files (*.mp3 *.wav *.ogg)")); + mFile = QFileDialog::getOpenFileName(this, "Open any audio file", QDir::homePath(), tr("Audio Files (*.mp3 *.wav *.ogg *.flac)")); if (mFile == NULL) { qDebug() << "File cannot be found"; msgbox.setWindowTitle("Uh oh! An error has occured!"); @@ -28,6 +26,7 @@ void Player::mFileDialog() msgbox.setIcon(QMessageBox::Information); msgbox.exec(); ui->volumeSlider->setValue(100); + ui->playButton->setText(tr("Play")); return; } } @@ -40,6 +39,9 @@ Player::Player(QWidget *parent) { ui->setupUi(this); + connect(mPlayer, &QMediaPlayer::positionChanged, this, &Player::on_positionChanged); + connect(mPlayer, &QMediaPlayer::durationChanged, this, &Player::on_durationChanged); + } Player::~Player() @@ -58,15 +60,17 @@ void Player::on_playButton_pressed() { ui->playbackSlider->setEnabled(true); ui->volumeSlider->setEnabled(true); + if (mPlayer->state() == mPlayer->PlayingState) { qDebug() << "Pausing music..."; mPlayer->pause(); - ui->playButton->setText("Pause"); + ui->playButton->setText(tr("Play")); } else { qDebug() << "Playing music..."; mPlayer->play(); - ui->playButton->setText("Play"); + ui->playButton->setText(tr("Pause")); } + } void Player::on_stopButton_pressed() @@ -101,3 +105,18 @@ void Player::on_volumeSlider_sliderMoved(int position) { mPlayer->setVolume(position); } + +void Player::on_playbackSlider_sliderMoved(int position) +{ + mPlayer->setPosition(position); +} + +void Player::on_positionChanged(qint64 position) +{ + ui->playbackSlider->setValue(position); +} + +void Player::on_durationChanged(qint64 position) +{ + ui->playbackSlider->setMaximum(position); +} diff --git a/player.h b/player.h index fae3e58..efecef9 100644 --- a/player.h +++ b/player.h @@ -34,6 +34,12 @@ private slots: void on_volumeSlider_sliderMoved(int position); + void on_playbackSlider_sliderMoved(int position); + + void on_positionChanged(qint64 position); + + void on_durationChanged(qint64 position); + private: Ui::Player *ui; }; diff --git a/player.ui b/player.ui index 4df7103..312c8d7 100644 --- a/player.ui +++ b/player.ui @@ -15,8 +15,28 @@ - - + + + + false + + + Qt::Horizontal + + + + + + + Browse + + + false + + + + + Qt::Horizontal @@ -28,7 +48,7 @@ - + false @@ -47,13 +67,6 @@ - - - - Volume - - - @@ -88,31 +101,8 @@ - - - - false - - - Qt::Horizontal - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - + + Qt::Horizontal @@ -140,18 +130,21 @@ - - - - Stop + + + + Qt::Horizontal - - false + + + 40 + 20 + - + - - + + Qt::Horizontal @@ -163,10 +156,17 @@ - - + + - Browse + Volume + + + + + + + Stop false -- cgit v1.2.3