private void RepositionTest() { if (String.IsNullOrEmpty(InputFile)) { MessageBox.Show("Select a file first"); return; } var saveFile = SelectSaveFile("reposition"); if (saveFile == null) { return; } // do the resample using (var reader = new MediaFoundationReader(InputFile)) using (var resampler = new MediaFoundationResampler(reader, CreateOutputFormat(reader.WaveFormat))) { CreateRepositionTestFile(saveFile, resampler, () => { // tell the reader to go back to the start (we're trusting it not to have leftovers) reader.Position = 0; // tell the resampler that we have repositioned and it should drain all its buffers resampler.Reposition(); }); } // use the following to test that just the reader is doing clean repositions: /* * using (var reader = new MediaFoundationReader(InputFile)) * { * CreateRepositionTestFile(saveFile, reader, () => * { * // tell the reader to go back to the start (we're trusting it not to have leftovers) * reader.Position = 0; * }); * }*/ MessageBox.Show("Resample complete"); }