使用Windows 10 IOT Core在Raspberry Pi中播放wav文件

vil*_*rci 1 c# raspberry-pi2 windows-10-iot-core windowsiot

有人可以给我一些关于如何在Windows 10下在Raspberry Pi上播放简单wav文件的开始吗?我想要的是将几个文件加载到内存和特定事件中,如果可能的话,开始播放它们,同时播放声音.我尝试了这个,但它失败了DLLImport行(未找到CoreDll.dll).因此,非常欢迎任何聪明的链接或样本.谢谢,vm

我创建了一个简单的测试项目,它运行,没有错误退出,但我只听到沉默.难道我做错了什么?我预计下面的代码会播放50次短鼓样本.

namespace BackTC
{
    public sealed class StartupTask : IBackgroundTask
    {
        public void Run(IBackgroundTaskInstance taskInstance)
        {
            btnPlayWavSound_Tapped();
        }


        private async void btnPlayWavSound_Tapped()
        {

            StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/CLudwigKick-Dyn01.WAV"));
            MediaPlayer player = BackgroundMediaPlayer.Current;
            player.SetFileSource(file);


            for (int i = 1; i <= 50; i++)
            {
                player.Volume = 100;
                player.Play();
            }

        }

    }
}
Run Code Online (Sandbox Code Playgroud)

hac*_*ker 7

我有以下代码可以在后台应用程序项目中工作,它从Assets文件夹中读取WAV文件.不要忘记将WAV文件设置为复制到输出目录.

StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/filename.wav"));
MediaPlayer player = BackgroundMediaPlayer.Current;
player.AutoPlay = false;
player.SetFileSource(file);
player.Play();
Run Code Online (Sandbox Code Playgroud)