How to play audio from resource

前端 未结 4 961
梦如初夏
梦如初夏 2020-12-20 21:32

I am trying to play audio from a resource using .NET Compact Framework. I added an audio file for the resource property in my application and am trying to use the below samp

4条回答
  •  醉梦人生
    2020-12-20 21:50

    This should work for you:

    Stream str = Properties.Resources.YourWaveSoundFile;
    SoundPlayer plyr = new SoundPlayer(str);
    plyr.Play();
    

    Make sure you have using System.Media above your namespace.

提交回复
热议问题