From d9e6d8d752000676cf5ea9489f044db78ef12b69 Mon Sep 17 00:00:00 2001 From: Arno Date: Mon, 27 Feb 2017 12:34:23 +0100 Subject: Advance to next song from playlist when the current one has finished. --- playerwidget.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'playerwidget.cpp') diff --git a/playerwidget.cpp b/playerwidget.cpp index 33d8e9b..7e70125 100644 --- a/playerwidget.cpp +++ b/playerwidget.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include @@ -33,6 +32,7 @@ void PlayerWidget::setupGui(){ mPlayer = new QMediaPlayer(this); connect(mPlayer, SIGNAL(positionChanged(qint64)), this, SLOT(setPosition(qint64))); connect(mPlayer, SIGNAL(durationChanged(qint64)), this, SLOT(setDuration(qint64))); + connect(mPlayer, SIGNAL(stateChanged(QMediaPlayer::State)), this, SLOT(continuePlaying(QMediaPlayer::State))); //THE view mView = new BeetView; @@ -459,13 +459,13 @@ void PlayerWidget::randomPlay(){ } void PlayerWidget::playCurrent(const QModelIndex &index){ + mStopA->trigger(); QString fullPath = index.data(FullPathRole).toString(); play(fullPath); } void PlayerWidget::play(const QString &fullPath){ mPlayer->setMedia(QUrl::fromLocalFile(fullPath)); - mPlayA->trigger(); } @@ -528,3 +528,9 @@ void PlayerWidget::setDuration(qint64 dur){ mSongSlider->setMinimum(0); mSongSlider->setMaximum(durSecs); } + +void PlayerWidget::continuePlaying(QMediaPlayer::State state){ + if(mPlayA->isChecked() && state == QMediaPlayer::StoppedState){ + next(); + } +} -- cgit v1.2.3-70-g09d2