From 365a050e707b10cb2f75ee1697cb77037c99ea65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Aguilera=20Puerto?= Date: Thu, 4 Jun 2020 20:53:51 +0200 Subject: [PATCH] Fix bug where choosing a MIDI song while one was already playing broke MIDI We just delay playing the new song 0.1 seconds. --- Content.Client/Instruments/InstrumentMenu.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Content.Client/Instruments/InstrumentMenu.cs b/Content.Client/Instruments/InstrumentMenu.cs index 683a96c359..81154acd55 100644 --- a/Content.Client/Instruments/InstrumentMenu.cs +++ b/Content.Client/Instruments/InstrumentMenu.cs @@ -1,3 +1,4 @@ +using System.Threading.Tasks; using Content.Client.GameObjects.Components.Instruments; using Content.Client.UserInterface.Stylesheets; using Robust.Client.Audio.Midi; @@ -10,6 +11,7 @@ using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Log; using Robust.Shared.Maths; +using Robust.Shared.Timers; namespace Content.Client.Instruments { @@ -174,7 +176,7 @@ namespace Content.Client.Instruments var filters = new FileDialogFilters(new FileDialogFilters.Group("mid", "midi")); var filename = await _fileDialogManager.OpenFile(filters); - if (filename == null) return; + if (string.IsNullOrEmpty(filename)) return; if (!_midiManager.IsMidiFile(filename)) { @@ -183,6 +185,7 @@ namespace Content.Client.Instruments } MidiStopButtonOnPressed(null); + await Timer.Delay(100); if (!_owner.Instrument.OpenMidi(filename)) return; MidiPlaybackSetButtonsDisabled(false); if (midiInputButton.Pressed)