Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to skip when both decks are playing on auto dj #2531

Merged
merged 5 commits into from
Mar 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Prevent infinite loop when decoding corrupt MP3 files #2417
* Add controller mapping for Native Instruments Traktor Kontrol S2 MK3 #2348
* Add controller mapping for Soundless joyMIDI #2425
* AutoDJ skip next track when both deck are playing lp:1399974 #2531

==== 2.2.3 2019-11-24 ====
* Don't make users reconfigure sound hardware when it has not changed #2253
Expand Down
20 changes: 17 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,11 @@ 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 +695,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