diff --git a/App/Presenters/Controls/MusicControlPresenter.cs b/App/Presenters/Controls/MusicControlPresenter.cs index 69be815..86e5f5b 100644 --- a/App/Presenters/Controls/MusicControlPresenter.cs +++ b/App/Presenters/Controls/MusicControlPresenter.cs @@ -1,5 +1,6 @@ using System; using System.ComponentModel; +using System.IO; using System.Threading; using System.Timers; using CollectionManager.DataTypes; @@ -102,7 +103,7 @@ private void ModelOnBeatmapChanged(object sender, EventArgs eventArgs) if (map == null || !_view.IsAutoPlayEnabled) return; var audioLocation = ((BeatmapExtension)map).FullAudioFileLocation(); - if ((_lastAudioFileLocation == audioLocation || string.IsNullOrWhiteSpace(audioLocation)) && _view.IsMusicPlayerMode && !musicPlayer.IsPlaying) + if (ShouldSkipTrack(audioLocation)) { //Run as worker to avoid eventual stack overflow exception (eg. too many maps with no audio file in a row) RunAsWorker(() => _model.EmitNextMapRequest()); @@ -112,6 +113,14 @@ private void ModelOnBeatmapChanged(object sender, EventArgs eventArgs) PlayBeatmap(map); } + private bool ShouldSkipTrack(string audioLocation) + { + if ((_lastAudioFileLocation == audioLocation || string.IsNullOrWhiteSpace(audioLocation)) && + _view.IsMusicPlayerMode && !musicPlayer.IsPlaying) + return true; + + return !File.Exists(audioLocation); + } private void PlayBeatmap(Beatmap map) { var audioLocation = ((BeatmapExtension)map).FullAudioFileLocation();