今天的下午和晚上,我们共同完成了对MCIPlay.cs文件的编写和测试。

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Runtime.InteropServices;
 6 
 7 namespace PlayPlane_01
 8 {
 9     class MCIPlay
10     {
11         public static uint SND_ASYNC = 0x0001;
12         public static uint SND_FILENAME = 0x00020000;
13         [DllImport("winmm.dll")]
14         public static extern uint mciSendString(string lpstrCommand,
15         string lpstrReturnString, uint uReturnLength, uint hWndCallback);
16 
17         private string musicPath;
18 
19         public MCIPlay(string musicPath)
20         {
21             this.musicPath = musicPath;
22         }
23 
24         public void Play()
25         {
26             mciSendString(@"close temp_alias", null, 0, 0);
27             mciSendString(@"open "+musicPath+" alias temp_alias", null, 0, 0);
28             mciSendString("play temp_alias ", null, 0, 0);
29         }
30     }
31 }