using System.Runtime.InteropServices;public static uint SND_ASYNC = 0x0001; // play asynchronously public static uint SND_FILENAME = 0x00020000; // name is file name [DllImport("winmm.dll")] public static extern uint mciSendString(string lpstrCommand, string lpstrReturnString, uint uReturnLength, uint hWndCallback);private void button1_Click(object sender, EventArgs e) { mciSendString(@"close temp_alias", null, 0, 0); mciSendString(@"open ""E:\音乐\周杰伦-东风破.mp3"" alias temp_alias", null, 0, 0); mciSendString("play temp_alias repeat", null, 0, 0); }Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" ( _ ByVal lpszSoundName As String, ByVal uFlags As Long) As Long Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" ( _ ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _ ByVal uReturnLength As UInteger, ByVal hWndCallback As UInteger) As Long Const SND_ASYNC As Integer = &H1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click sndPlaySound("chord", SND_ASYNC) End SubPrivate Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load mciSendString("close temp_alias", Nothing, 0, 0) mciSendString("open ""E:\音乐\周杰伦-东风破.mp3"" alias temp_alias", Nothing, 0, 0) mciSendString("play temp_alias repeat", Nothing, 0, 0) End Sub
//以MUSIC下面的文件个数为上限,从0开始产生随机数 //将产生的随机数作为字符串数组MUSFiles下标, //通过此下标来指定要显示的文件名 Random r=new Random (); //播放获取的音频或视频文件 .......................请帮忙.............
{
string mp3File=Application.StartupPath+"\\mp3\\你若成风.mp3";
QuartzTypeLib.FilgraphManager graphManager=new QuartzTypeLib.FilgraphManager ;
QuartzTypeLib.IMediaControl mycontrol=(QuartzTypeLib.IMediaControl)graphManager;
mycontrol.RenderFile(mp3File);
mycontrol.Run();
}
使用quartz.dll(DX提供的一个音频解码类),然后在播放结束事件中,再次调用 mycontrol.Run() 就可实现循环播放了
public static uint SND_FILENAME = 0x00020000; // name is file name
[DllImport("winmm.dll")]
public static extern uint mciSendString(string lpstrCommand,
string lpstrReturnString, uint uReturnLength, uint hWndCallback);private void button1_Click(object sender, EventArgs e)
{
mciSendString(@"close temp_alias", null, 0, 0);
mciSendString(@"open ""E:\音乐\周杰伦-东风破.mp3"" alias temp_alias",
null, 0, 0);
mciSendString("play temp_alias repeat", null, 0, 0);
}Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" ( _
ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" ( _
ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _
ByVal uReturnLength As UInteger, ByVal hWndCallback As UInteger) As Long
Const SND_ASYNC As Integer = &H1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
sndPlaySound("chord", SND_ASYNC)
End SubPrivate Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
mciSendString("close temp_alias", Nothing, 0, 0)
mciSendString("open ""E:\音乐\周杰伦-东风破.mp3"" alias temp_alias", Nothing, 0, 0)
mciSendString("play temp_alias repeat", Nothing, 0, 0)
End Sub
怎么实现啊?请高手帮忙! //Opacity
//存储音频或视频路径
//string MUSpath=null;
//读取当前目录名
string currentDir = Directory.GetCurrentDirectory();
//以此为根目录,读取MUSIC下面的文件,存储到字符串数组MUSFiles
string[] MUSFiles=Directory.GetFiles(currentDir+"\\MUSIC\\".ToString());
//以MUSIC下面的文件个数为上限,从0开始产生随机数
//将产生的随机数作为字符串数组MUSFiles下标,
//通过此下标来指定要显示的文件名
Random r=new Random (); //播放获取的音频或视频文件
.......................请帮忙.............
请问这个“播放结束事件”怎么写?