开发者

How to get names of embedded audio resource in .Net application

开发者 https://www.devze.com 2023-03-26 21:48 出处:网络
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

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
0

精彩评论

暂无评论...
验证码 换一张
取 消