How to get names of embedded audio resource in .Net application
I have added few audio wav files to my .net project. I want to get names of all the audio 开发者_开发知识库wav files within my .net application. My audio wav files are within resources.resx file which is internal to my project and will compile with it.
Following is my solution for playing embedded audio resource in .net application.
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
精彩评论