Skip to content

Commit

Permalink
ability to skip when both decks are playing
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristiano Lacerda authored and Cristiano Lacerda committed Mar 6, 2020
1 parent adb2c3c commit 9387e26
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
22 changes: 19 additions & 3 deletions src/library/autodj/autodjprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,18 @@ AutoDJProcessor::AutoDJError AutoDJProcessor::skipNext() {
} else if (!rightDeck.isPlaying()) {
removeLoadedTrackFromTopOfQueue(rightDeck);
loadNextTrackFromQueue(rightDeck);
} else {
// If both decks are playing remove next track in playlist
TrackId nextId = m_pAutoDJTableModel->getTrackId(m_pAutoDJTableModel->index(0, 0));
TrackId leftId = leftDeck.getLoadedTrack()->getId();
TrackId rightId = rightDeck.getLoadedTrack()->getId();
if (nextId == leftId || nextId == rightId) {
// One of the playing tracks is still on top of playlist, remove second item
m_pAutoDJTableModel->removeTrack(m_pAutoDJTableModel->index(1, 0));
} else {
m_pAutoDJTableModel->removeTrack(m_pAutoDJTableModel->index(0, 0));
}
maybeFillRandomTracks();
}
return ADJ_OK;
}
Expand Down Expand Up @@ -668,7 +680,13 @@ bool AutoDJProcessor::removeTrackFromTopOfQueue(TrackPointer pTrack) {
m_pAutoDJTableModel->appendTrack(nextId);
}

// Fill random tracks if configured
maybeFillRandomTracks();

return true;
}

void AutoDJProcessor::maybeFillRandomTracks() {

int minAutoDJCrateTracks = m_pConfig->getValueString(
ConfigKey(kConfigKey, "RandomQueueMinimumAllowed")).toInt();
bool randomQueueEnabled = (((m_pConfig->getValueString(
Expand All @@ -679,8 +697,6 @@ bool AutoDJProcessor::removeTrackFromTopOfQueue(TrackPointer pTrack) {
qDebug() << "Randomly adding tracks";
emit(randomTrackRequested(tracksToAdd));
}

return true;
}

void AutoDJProcessor::playerPlayChanged(DeckAttributes* pAttributes, bool playing) {
Expand Down
2 changes: 1 addition & 1 deletion src/library/autodj/autodjprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class AutoDJProcessor : public QObject {
// Removes the provided track from the top of the AutoDJ queue if it is
// present.
bool removeTrackFromTopOfQueue(TrackPointer pTrack);

void maybeFillRandomTracks();
UserSettingsPointer m_pConfig;
PlayerManagerInterface* m_pPlayerManager;
PlaylistTableModel* m_pAutoDJTableModel;
Expand Down

0 comments on commit 9387e26

Please sign in to comment.