diff --git a/mythplugins/mythmusic/mythmusic/main.cpp b/mythplugins/mythmusic/mythmusic/main.cpp index cd3c716f354..2cc677f4060 100644 --- a/mythplugins/mythmusic/mythmusic/main.cpp +++ b/mythplugins/mythmusic/mythmusic/main.cpp @@ -591,6 +591,10 @@ static void setupKeys(void) "Decrease Play Speed"), "X"); REG_KEY("Music", "MARK", QT_TRANSLATE_NOOP("MythControls", "Toggle track selection"), "T"); + REG_KEY("Music", "TOGGLESHUFFLE", QT_TRANSLATE_NOOP("MythControls", + "Toggle shuffle mode"), ""); + REG_KEY("Music", "TOGGLEREPEAT", QT_TRANSLATE_NOOP("MythControls", + "Toggle repeat mode"), ""); // switch to view key bindings REG_KEY("Music", "SWITCHTOPLAYLIST", QT_TRANSLATE_NOOP("MythControls", diff --git a/mythplugins/mythmusic/mythmusic/musiccommon.cpp b/mythplugins/mythmusic/mythmusic/musiccommon.cpp index 0dc05eb5f2c..39b67fb16ec 100644 --- a/mythplugins/mythmusic/mythmusic/musiccommon.cpp +++ b/mythplugins/mythmusic/mythmusic/musiccommon.cpp @@ -287,9 +287,14 @@ void MusicCommon::updateRepeatMode(void) break; } } + + // need this to update the next track info + Metadata *curMeta = gPlayer->getCurrentMetadata(); + if (curMeta) + updateTrackInfo(curMeta); } -void MusicCommon::updateShuffleMode(void) +void MusicCommon::updateShuffleMode(bool updateUIList) { if (m_shuffleState) { @@ -327,6 +332,24 @@ void MusicCommon::updateShuffleMode(void) break; } } + + if (updateUIList) + { + // store id of current track + int curTrackID = -1; + if (gPlayer->getCurrentMetadata()) + curTrackID = gPlayer->getCurrentMetadata()->ID(); + + updateUIPlaylist(); + + if (!restorePosition(curTrackID)) + playFirstTrack(); + + // need this to update the next track info + Metadata *curMeta = gPlayer->getCurrentMetadata(); + if (curMeta) + updateTrackInfo(curMeta); + } } void MusicCommon::switchView(MusicView view) @@ -677,6 +700,16 @@ bool MusicCommon::keyPressEvent(QKeyEvent *e) switchView(MV_SEARCH); else if (action == "SWITCHTOVISUALISER" && m_currentView != MV_VISUALIZER) switchView(MV_VISUALIZER); + else if (action == "TOGGLESHUFFLE") + { + gPlayer->toggleShuffleMode(); + updateShuffleMode(true); + } + else if (action == "TOGGLEREPEAT") + { + gPlayer->toggleRepeatMode(); + updateRepeatMode(); + } else handled = false; } @@ -1294,22 +1327,7 @@ void MusicCommon::customEvent(QEvent *event) { int mode = dce->GetData().toInt(); gPlayer->setShuffleMode((MusicPlayer::ShuffleMode) mode); - updateShuffleMode(); - - // store id of current track - int curTrackID = -1; - if (gPlayer->getCurrentMetadata()) - curTrackID = gPlayer->getCurrentMetadata()->ID(); - - updateUIPlaylist(); - - if (!restorePosition(curTrackID)) - playFirstTrack(); - - // need this to update the next track info - Metadata *curMeta = gPlayer->getCurrentMetadata(); - if (curMeta) - updateTrackInfo(curMeta); + updateShuffleMode(true); } else if (resultid == "exitmenu") { diff --git a/mythplugins/mythmusic/mythmusic/musiccommon.h b/mythplugins/mythmusic/mythmusic/musiccommon.h index 78aaa386d2b..014110a3686 100644 --- a/mythplugins/mythmusic/mythmusic/musiccommon.h +++ b/mythplugins/mythmusic/mythmusic/musiccommon.h @@ -115,7 +115,7 @@ class MPUBLIC MusicCommon : public MythScreenType void updatePlaylistStats(void); void updateUIPlayedList(void); // for streaming void updateRepeatMode(void); - void updateShuffleMode(void); + void updateShuffleMode(bool updateUIList = false); void changeVolume(bool up); void changeSpeed(bool up);