diff --git a/src/audiomanager.cpp b/src/audiomanager.cpp index 46810712..86dde16f 100644 --- a/src/audiomanager.cpp +++ b/src/audiomanager.cpp @@ -125,12 +125,12 @@ bool AudioManager::canPause() const return (d->m_readyToPlay); } -bool AudioManager::canGoNext() const +bool AudioManager::canSkipForward() const { return (d->m_readyToPlay); } -bool AudioManager::canGoPrevious() const +bool AudioManager::canSkipBackward() const { return (d->m_readyToPlay); } @@ -207,14 +207,14 @@ void AudioManager::setEntry(Entry* entry) Q_EMIT entryChanged(entry); Q_EMIT canPlayChanged(); Q_EMIT canPauseChanged(); - Q_EMIT canGoNextChanged(); - Q_EMIT canGoPreviousChanged(); + Q_EMIT canSkipForwardChanged(); + Q_EMIT canSkipBackwardChanged(); } else { d->m_readyToPlay = false; Q_EMIT canPlayChanged(); Q_EMIT canPauseChanged(); - Q_EMIT canGoNextChanged(); - Q_EMIT canGoPreviousChanged(); + Q_EMIT canSkipForwardChanged(); + Q_EMIT canSkipBackwardChanged(); } } @@ -296,15 +296,15 @@ void AudioManager::seek(qint64 position) d->m_player.setPosition(position); } -void AudioManager::next() +void AudioManager::skipForward() { - qDebug() << "AudioManager::next"; + qDebug() << "AudioManager::skipForward"; seek(std::min((position() + SKIP_STEP), duration())); } -void AudioManager::previous() +void AudioManager::skipBackward() { - qDebug() << "AudioManager::previous"; + qDebug() << "AudioManager::skipBackward"; seek(std::max((qint64)0, (position() - SKIP_STEP))); } diff --git a/src/audiomanager.h b/src/audiomanager.h index 239e85ac..595f5f69 100644 --- a/src/audiomanager.h +++ b/src/audiomanager.h @@ -125,9 +125,9 @@ public: [[nodiscard]] bool canPause() const; - [[nodiscard]] bool canGoNext() const; + [[nodiscard]] bool canSkipForward() const; - [[nodiscard]] bool canGoPrevious() const; + [[nodiscard]] bool canSkipBackward() const; Q_SIGNALS: @@ -165,9 +165,9 @@ Q_SIGNALS: void canPauseChanged(); - void canGoNextChanged(); + void canSkipForwardChanged(); - void canGoPreviousChanged(); + void canSkipBackwardChanged(); public Q_SLOTS: @@ -195,9 +195,9 @@ public Q_SLOTS: void seek(qint64 position); - void previous(); + void skipBackward(); - void next(); + void skipForward(); private Q_SLOTS: diff --git a/src/mpris2/mediaplayer2player.cpp b/src/mpris2/mediaplayer2player.cpp index 30c8d5c2..1f453c46 100644 --- a/src/mpris2/mediaplayer2player.cpp +++ b/src/mpris2/mediaplayer2player.cpp @@ -104,7 +104,7 @@ void MediaPlayer2Player::Next() emit next(); if (m_audioPlayer) { - m_audioPlayer->next(); + m_audioPlayer->skipForward(); } } @@ -116,7 +116,11 @@ bool MediaPlayer2Player::CanGoPrevious() const void MediaPlayer2Player::Previous() { - // not implemented + emit previous(); + + if (m_audioPlayer) { + m_audioPlayer->skipBackward(); + } } bool MediaPlayer2Player::CanPause() const diff --git a/src/qml/PlayerControls.qml b/src/qml/PlayerControls.qml index 2ffbe1a5..d9801b7e 100644 --- a/src/qml/PlayerControls.qml +++ b/src/qml/PlayerControls.qml @@ -174,7 +174,7 @@ Kirigami.Page { icon.width: parent.buttonsize flat: true Layout.alignment: Qt.AlignHCenter - onClicked: audio.previous() + onClicked: audio.skipBackward() } Controls.Button { id: playButton @@ -191,7 +191,7 @@ Kirigami.Page { icon.width: parent.buttonsize flat: true Layout.alignment: Qt.AlignHCenter - onClicked: audio.next() + onClicked: audio.skipForward() } Controls.Button { icon.name: "media-skip-forward" @@ -199,7 +199,7 @@ Kirigami.Page { icon.width: parent.buttonsize flat: true Layout.alignment: Qt.AlignHCenter - onClicked: audio.next() + onClicked: console.log("Next track to be implemented") } } }