简体   繁体   English

如何使用c#中的windows media player在资源中播放.mid声音

[英]How to play .mid Sound in resources using windows media player in c#

I want to play a mid sound which embedded in my resources file , its in byte , I searched a lot I found most answers like this ,I changed it to my resouces like this 我想打一个中等声音,嵌在我的资源文件,它以字节,我搜索了很多,我发现大多数答案像这样 ,我把它改成我resouces这样

 Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("WindowsFormsApplication1.Properties.Resources.music.mid");

but it gives me an exception of null 但它给了我一个null的例外

, waht I excactly want is to read this sound , if in byte or another alternative way possible . ,我想要的是读取这个声音,如果是字节或其他替代方式可能。

If you simply set file's build action as Embedded Resource you can access it using: 如果您只是将文件的构建操作设置为嵌入式资源,则可以使用以下命令访问它:

Assembly.GetExecutingAssembly().GetManifestResourceStream("WindowsFormsApplication1.music.mid")

If it doesn't work use this code to find the exact name: 如果不起作用,请使用此代码查找确切名称:

For Each strResource As String In Assembly.GetExecutingAssembly().GetManifestResourceNames()
    MsgBox(strResource)
Next strResource

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM