📄 music.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Media;
using System.Runtime.InteropServices;
//=======================================================================
//本程序由本人独立完成,允许修改,但请保留本处.
//联系方式:blessyou312@163.com
//blog:blog.csdn.net/blessyou312 hi.baidu.com/blessyou312
//=======================================================================
namespace LLK
{
class Music
{
[DllImport("winmm.dll")]
private static extern int mciSendString
(
string lpstrCommand,
string lpstrReturnString,
int uReturnLength,
int hwndCallback
);
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern int GetShortPathName
(
[MarshalAs(UnmanagedType.LPTStr)] string path,
[MarshalAs(UnmanagedType.LPTStr)] StringBuilder shortPath,
int shortPathLength
);
public void Play(string FileName)
{
StringBuilder shortPathTemp = new StringBuilder(255);
int result = GetShortPathName(FileName, shortPathTemp, shortPathTemp.Capacity);
string ShortPath = shortPathTemp.ToString();
mciSendString("open " + ShortPath + " alias song", "", 0, 0);
mciSendString("play song", "", 0, 0);
}
public void Stop()
{
mciSendString("stop song", "", 0, 0);
}
public void Pause()
{
mciSendString("pause song", "", 0, 0);
}
public void Close()
{
mciSendString("close song", "", 0, 0);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -