【问题标题】:How to get names of embedded audio resource in .Net application如何在.Net应用程序中获取嵌入式音频资源的名称
【发布时间】:2011-10-22 08:32:23
【问题描述】:

我在我的 .net 项目中添加了一些音频 wav 文件。我想在我的 .net 应用程序中获取所有音频 wav 文件的名称。我的音频 wav 文件位于我的项目内部的 resources.resx 文件中,并将使用它进行编译。

【问题讨论】:

    标签: .net embedded-resource


    【解决方案1】:

    以下是我在 .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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-11-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多