Closed. This question needs to be more focused。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗?更新问题,使其仅通过editing this post专注于一个问题。
                        
                        在10个月前关闭。
                                                                                            
                
        
如何直接从内存(例如资源)播放MIDI文件?
我发现this作为解决方案,但我不了解如何从资源中播放MIDI。请使用正确的WinAPI命令帮助我

最佳答案

好的,我提出了一个临时解决方案。
仍然有效

using (var midiStream = new MemoryStream(Resources.myMidi))
        {
            var data = midiStream.ToArray();
            try
            {
                using (var fs = new FileStream("midi.mid", FileMode.CreateNew, FileAccess.Write))
                {
                    fs.Write(data, 0, data.Length);
                }
            }
            catch(IOException)
            {}
            string sCommand = "open \"" + Application.StartupPath + "/midi.mid" + "\" alias " + "MIDIapp";
            mciSendString(sCommand, null, 0, IntPtr.Zero);
            sCommand = "play " + "MIDIapp";
            mciSendString(sCommand, null, 0, IntPtr.Zero);
        }

10-07 16:48