-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMP3_player.cs
40 lines (35 loc) · 1.06 KB
/
MP3_player.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace Graphics
{
class MP3_player
{
[DllImport("winmm.dll")]
private static extern long mciSendString(string lpstrCommand, StringBuilder lpstrReturnString, int uReturnLength, int hwdCallBack);
public void open(string file_name)
{
string format = @"open ""{0}"" type MPEGVideo alias MediaFile";
string command = string.Format(format, file_name);
mciSendString(command, null, 0, 0);
}
public void play()
{
string command = "play MediaFile";
mciSendString(command, null, 0, 0);
}
public void PlayLooping()
{
string command = "play MediaFile REPEAT";
mciSendString(command, null, 0, 0);
}
public void stop()
{
string command = "stop MediaFile";
mciSendString(command, null, 0, 0);
}
}
}