diff --git a/src/musikbox/app/layout/BrowseLayout.cpp b/src/musikbox/app/layout/BrowseLayout.cpp index 09a3f4b9b..f8d365843 100755 --- a/src/musikbox/app/layout/BrowseLayout.cpp +++ b/src/musikbox/app/layout/BrowseLayout.cpp @@ -142,12 +142,16 @@ void BrowseLayout::OnCategoryViewInvalidated( bool BrowseLayout::KeyPress(const std::string& key) { if (key == "^M") { /* enter. play the selection */ auto tracks = this->trackList->GetTrackList(); - auto focus = this->GetFocus(); - size_t index = (focus == this->trackList) - ? this->trackList->GetSelectedIndex() : 0; + if (tracks && tracks->size()) { + auto focus = this->GetFocus(); + + size_t index = (focus == this->trackList) + ? this->trackList->GetSelectedIndex() : 0; + + this->playback.Play(*tracks, index); + } - this->playback.Play(*tracks, index); return true; } if (key == "KEY_F(5)") { diff --git a/src/musikbox/app/service/PlaybackService.cpp b/src/musikbox/app/service/PlaybackService.cpp index 5d84286d0..356c80b82 100755 --- a/src/musikbox/app/service/PlaybackService.cpp +++ b/src/musikbox/app/service/PlaybackService.cpp @@ -137,7 +137,9 @@ void PlaybackService::Play(std::vector& tracks, size_t index) { std::swap(temp, this->playlist); } - this->Play(index); + if (index <= tracks.size()) { + this->Play(index); + } } void PlaybackService::Copy(std::vector& target) {