private void clearPreviousSamples() { // only run if the samples aren't already cleared. // this ensures the "wasPlaying" state is stored correctly even if multiple clear calls are executed. if (!sampleContainer.Any()) { return; } wasPlaying = Playing; sampleContainer.Clear(); Sample = null; }
private void updateSample() { if (sampleInfo == null) { return; } bool wasPlaying = Playing; sampleContainer.Clear(); Sample = null; var ch = CurrentSkin.GetSample(sampleInfo); if (ch == null && AllowDefaultFallback) { foreach (var lookup in sampleInfo.LookupNames) { if ((ch = sampleStore.Get(lookup)) != null) { break; } } } if (ch == null) { return; } sampleContainer.Add(Sample = new DrawableSample(ch) { Looping = Looping }); // Start playback internally for the new sample if the previous one was playing beforehand. if (wasPlaying && Looping) { Play(); } }