Skip to content

Commit

Permalink
clear the queue before playing bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
janbar committed Feb 28, 2018
1 parent eebf33c commit 36f2958
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 19 deletions.
6 changes: 5 additions & 1 deletion backend/modules/NosonApp/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,11 @@ int Player::addMultipleItemsToQueue(const QVariantList& payloads)

bool Player::removeAllTracksFromQueue()
{
return m_player ? m_player->RemoveAllTracksFromQueue() : false;
if (m_player && m_player->RemoveAllTracksFromQueue()) {
m_currentIndex = -1;
return true;
}
return false;
}

bool Player::removeTrackFromQueue(const QString& id, int containerUpdateID)
Expand Down
15 changes: 9 additions & 6 deletions gui/noson.qml
Original file line number Diff line number Diff line change
Expand Up @@ -454,12 +454,15 @@ ApplicationWindow {
// Action on play all button clicked
function playAll(modelItem)
{
var nr = player.addItemToQueue(modelItem, 0);
if (nr && player.playQueue(false) && player.seekTrack(nr) && player.play()) {
// Show the Now playing page and make sure the track is visible
tabs.pushNowPlaying();
popInfo.open(qsTr("song added"));
return true;
// replace queue with the bundle item
if (player.removeAllTracksFromQueue()) {
var nr = player.addItemToQueue(modelItem, 0);
if (nr && player.playQueue(false) && player.seekTrack(nr) && player.play()) {
// Show the Now playing page and make sure the track is visible
tabs.pushNowPlaying();
popInfo.open(qsTr("song added"));
return true;
}
}
popInfo.open(qsTr("Action can't be performed"));
return false;
Expand Down
17 changes: 11 additions & 6 deletions gui/ui/Favorites.qml
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,17 @@ MusicPage {
}

Timer {
id: delayfavoriteClicked
id: delayFavoritePlayAll
interval: 100
property QtObject model
onTriggered: {
player.playFavorite(model) // play favorite
// clear queue when playing bundle
if (model.type !== 5 && model.canQueue) {
if (player.removeAllTracksFromQueue())
player.playFavorite(model);
} else {
player.playFavorite(model);
}
}
}

Expand Down Expand Up @@ -249,12 +255,11 @@ MusicPage {
})
}
else if (model.type === 5) {
delayfavoriteClicked.model = model
delayfavoriteClicked.start()
player.playFavorite(model) // play it
}
} else {
delayfavoriteClicked.model = model
delayfavoriteClicked.start()
delayFavoritePlayAll.model = model
delayFavoritePlayAll.start()
}
}
}
16 changes: 10 additions & 6 deletions gui/ui/Service.qml
Original file line number Diff line number Diff line change
Expand Up @@ -298,18 +298,22 @@ MusicPage {
mediaModel.asyncLoadChild(model.id, model.title, servicePage.displayType, model.index);
} else if (model.canPlay) {
if (model.canQueue)
trackClicked(model);
trackClicked(model);
else
radioClicked(model);
radioClicked(model);
}
}

function playItem(model) {
if (model.canPlay) {
if (model.canQueue)
trackClicked(model);
else
radioClicked(model);
if (model.canQueue) {
if (model.isContainer)
playAll(model);
else
trackClicked(model);
} else {
radioClicked(model);
}
}
}

Expand Down

0 comments on commit 36f2958

Please sign in to comment.