public void ClearFile() { Stop(); audioPlayback.Init(EmptySampleProvider.Singleton); audioFile = null; CurrentWaveform = null; RenderWaveformAsync(false).Forget(); MusicFileName = null; }
public async Task LoadFileAsync(string fileName) { try { audioFile = new BufferedAudioFile(fileName); } catch (Exception e) { System.Windows.MessageBox.Show("Could not load music file: " + Path.GetFileName(fileName) + Environment.NewLine + Environment.NewLine + e.Message, "Problem opening file", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning); return; } MusicFileName = fileName; // TODO progress inidicator for file loading audioFile.LoadIntoMemoryAsync(null).Forget(); audioPlayback.Init(audioFile.CreateStream(infinite: true)); // Initialize our user-facing value from the playback device (which apparently gets its value from Windows). MusicVolume = LoudnessHelper.VolumeFromLoudness(audioPlayback.Volume); CurrentWaveform = null; await RenderWaveformAsync(false); Notify(nameof(MusicDuration)); }