【发布时间】:2011-10-22 08:32:23
【问题描述】:
我在我的 .net 项目中添加了一些音频 wav 文件。我想在我的 .net 应用程序中获取所有音频 wav 文件的名称。我的音频 wav 文件位于我的项目内部的 resources.resx 文件中,并将使用它进行编译。
【问题讨论】:
我在我的 .net 项目中添加了一些音频 wav 文件。我想在我的 .net 应用程序中获取所有音频 wav 文件的名称。我的音频 wav 文件位于我的项目内部的 resources.resx 文件中,并将使用它进行编译。
【问题讨论】:
以下是我在 .net 应用程序中播放嵌入式音频资源的解决方案。
Dim mSound As String = "Bell"
Dim strNameSpace As String = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name.ToString()
Dim mRes As Resources.ResourceManager = New Resources.ResourceManager(strNameSpace & ".Resources", Assembly.GetExecutingAssembly)
If mRes IsNot Nothing Then
Dim mSoundStream As Stream = mRes.GetStream(mSound)
If mSoundStream IsNot Nothing Then
Dim mPlayer As SoundPlayer = New SoundPlayer(mSoundStream)
mPlayer.Play()
mPlayer.Dispose()
mSoundStream.Close()
mSoundStream.Dispose()
End If
End If
【讨论】: