Fix bug where choosing a MIDI song while one was already playing broke MIDI

We just delay playing the new song 0.1 seconds.
This commit is contained in:
Víctor Aguilera Puerto
2020-06-04 20:53:51 +02:00
parent a89e806a50
commit 365a050e70

View File

@@ -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)