Csharp的音乐播放类.docVIP

  • 6
  • 0
  • 约2.06万字
  • 约 20页
  • 2016-08-22 发布于河南
  • 举报
Csharp的音乐播放类

MP3 类一 using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace KJJ class API { public const int WM_SYSCOMMAND = 0x112; public const int SC_MOVE = 0xF010; public const int HTCAPTION = 0x2; [DllImportAttribute(user32.dll)] public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); [DllImportAttribute(user32.dll)] public static extern bool ReleaseCapture(); [DllImport(kernel32.dll, CharSet = CharSet.Auto)] public static extern int GetShortPathName(string lpszLongPath, string shortFile, int cchBuffer); [DllImport(winmm.dll, EntryPoint = mciSendString, CharSet = CharSet.Auto)] public static extern int mciSendString(string lpstrCommand, string lpstrReturnString, int uReturnLength, int hwndCallback); } } MP3 类二 class Form32 { public static void OpenAndPlay(string strFileName, bool flagRepeat) { string strCommand = ; string buf = ; strCommand = open \ + strFileName + \ alias music; buf = buf.PadLeft(128, ); API.mciSendString(strCommand, buf, buf.Length, 0); if (flagRepeat) { strCommand = play music repeat; } else { strCommand = play music; } API.mciSendString(strCommand, buf, buf.Length, 0); } public static void Play(bool flagRepeat) { string strCommand = ; if (flagRepeat) { strCommand = play music repeat; } else { strCommand = play music; } API.mciSendString(strCommand, , 0, 0); } public static bool SetProcess(int nPosition) { bool success = false; string strCommand = string.Format(seek music to {0}, nPosition); if (API.mciSendString(strCommand, , 0, 0) == 0) { success = true; } return succ

文档评论(0)

1亿VIP精品文档

相关文档