mirror of
https://github.com/HenkKalkwater/harbour-sailfin.git
synced 2024-11-25 18:35:17 +00:00
Skip to song when clicking in the queue
This commit is contained in:
parent
f09593c245
commit
75474e1793
|
@ -148,6 +148,11 @@ public slots:
|
||||||
*/
|
*/
|
||||||
void playItem(Item *item);
|
void playItem(Item *item);
|
||||||
void playItemInList(ItemModel *itemList, int index);
|
void playItemInList(ItemModel *itemList, int index);
|
||||||
|
/**
|
||||||
|
* @brief skipToItemIndex Skips to an item in the current playlist
|
||||||
|
* @param index The index to skip to
|
||||||
|
*/
|
||||||
|
void skipToItemIndex(int index);
|
||||||
void play() { m_mediaPlayer->play(); }
|
void play() { m_mediaPlayer->play(); }
|
||||||
void pause() { m_mediaPlayer->pause(); }
|
void pause() { m_mediaPlayer->pause(); }
|
||||||
void seek(qint64 pos) { m_mediaPlayer->setPosition(pos); }
|
void seek(qint64 pos) { m_mediaPlayer->setPosition(pos); }
|
||||||
|
|
|
@ -165,6 +165,7 @@ void Playlist::play(int index) {
|
||||||
m_nextItem.clear();
|
m_nextItem.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
m_currentItem = m_list[m_shuffler->currentItem()];
|
||||||
emit currentItemChanged();
|
emit currentItemChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -192,6 +192,20 @@ void PlaybackManager::playItemInList(ItemModel *playlist, int index) {
|
||||||
setItem(playlist->itemAt(index));
|
setItem(playlist->itemAt(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlaybackManager::skipToItemIndex(int index) {
|
||||||
|
if (index < m_queue->queueSize()) {
|
||||||
|
// Skip until we hit the right number in the queue
|
||||||
|
index++;
|
||||||
|
while(index != 0) {
|
||||||
|
m_queue->next();
|
||||||
|
index--;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
m_queue->play(index);
|
||||||
|
}
|
||||||
|
setItem(m_queue->currentItem());
|
||||||
|
}
|
||||||
|
|
||||||
void PlaybackManager::next() {
|
void PlaybackManager::next() {
|
||||||
m_mediaPlayer->stop();
|
m_mediaPlayer->stop();
|
||||||
m_mediaPlayer->setMedia(QMediaContent());
|
m_mediaPlayer->setMedia(QMediaContent());
|
||||||
|
|
|
@ -7,6 +7,7 @@ import "music"
|
||||||
|
|
||||||
SilicaListView {
|
SilicaListView {
|
||||||
//header: PageHeader { title: qsTr("Play queue") }
|
//header: PageHeader { title: qsTr("Play queue") }
|
||||||
|
property var playbackManager
|
||||||
section.property: "section"
|
section.property: "section"
|
||||||
section.delegate: SectionHeader {
|
section.delegate: SectionHeader {
|
||||||
text: {
|
text: {
|
||||||
|
@ -29,6 +30,7 @@ SilicaListView {
|
||||||
indexNumber: index + 1
|
indexNumber: index + 1
|
||||||
duration: model.runTimeTicks
|
duration: model.runTimeTicks
|
||||||
playing: model.playing
|
playing: model.playing
|
||||||
|
onClicked: playbackManager.skipToItemIndex(model.index)
|
||||||
}
|
}
|
||||||
clip: true
|
clip: true
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,6 +98,12 @@ PanelBackground {
|
||||||
value: manager.queue
|
value: manager.queue
|
||||||
//currentIndex: manager.queueIndex
|
//currentIndex: manager.queueIndex
|
||||||
}
|
}
|
||||||
|
Binding {
|
||||||
|
when: queueLoader.item !== null
|
||||||
|
target: queueLoader.item
|
||||||
|
property: "playbackManager"
|
||||||
|
value: manager
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
|
|
Loading…
Reference in a new issue