This allows you to add the Audio project to your solution...

Playing wave files in Windows 10 with sharpdx, C# and XAML.

cassette

After trying the MediaElement in a Windows 10 Universal App, it seems it is still not the best choice for playing (fire-and-forget) wav files. It pops, clicks and cuts off samples. At least on my Windows 10 Technical Preview (Build 10061).

Native Direct X, shown in an earlier post, still works in a Windows 10 App, but I’d rather use SharpDX. The latest SharpDX (version 2.6.3) works in Windows 10.

You can download an updated project from Git. It is a Windows 10 (UAP) project and the Audio part is isolated in a separate UAP class library. This allows you to add the Audio project to your solution and use it like this:

private IWavePlayer _wavePlayer;

private async void MainPage_Loaded(object sender, RoutedEventArgs e) {
_wavePlayer = new WavePlayer();
await _wavePlayer.LoadWaves(Package.Current.InstalledLocation.Path + @"\Assets\Audio");
}

private void Button_Click1(object sender, RoutedEventArgs e) {
_wavePlayer.PlayWave("wav1.wav");
}

The LoadWaves method loads all the files in Assets/Audio and assumes they are WAV-files.

I hope this helps you to quickly implement wave playing in your App!

Written by Loek van den Ouweland on 2015-04-25.
Questions regarding this artice? You can send them to the address below.