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; }