Skip to content

Commit

Permalink
Merge pull request #2531 from crisclacerda/autodj-skip-playing
Browse files Browse the repository at this point in the history
Ability to skip when both decks are playing on auto dj
  • Loading branch information
daschuer authored Mar 8, 2020
2 parents adb2c3c + 828a82e commit b127ebf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
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

0 comments on commit b127ebf

Please sign in to comment.