如何播放从资源音频音频、资源

2023-09-03 01:31:40 作者:素年凉音

我试图使用Dot.net CF资源播放音频,我增加了一个音频文件,在我的应用程序的资源属性,并正在尝试使用下面的示例资源文件引用$ C $下。

Am trying to play audio from resource using Dot.net CF, I added an audio file for the resource Property in my application, and am try to using below sample resource file reference code for..

SoundPlayer player = new SoundPlayer(Assembly.GetExecutingAssembly().
    GetManifestResourceStream("blessedwav.wav"));
player.Play();

但是,这code不播放wav声音,如果有谁知道怎么玩CF使用3.5资源的音频文件,请给我这方面的一些建议。

But this code doesn't play wav sound, If anyone know How to play the resource audio file using CF 3.5, Please give me some suggestion regarding this.

推荐答案

我得到了solution.This code的工作非常好,在净CF:

I got the solution.This code is working very well in .Net CF:

// Convert a byte array to a stream
using (var audioStream = new MemoryStream(Properties.Resources.full_song_wav))
{
    using (var player = new SoundPlayer(audioStream))
    {
        player.Play()
    }
}