.NET播放音乐 - さびしい.Net/Java技术与技巧 - CSDN博客
来源:百度文库 编辑:神马文学网 时间:2024/04/29 11:37:57
.NET播放音乐 收藏
view plaincopy to clipboardprint?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsFormsMedia
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
[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
);
private void button1_Click(object sender, EventArgs e)
{
string buf = "";
buf = buf.PadLeft(128, ' ');
string file = @"F:\音乐\错错错.mp3"; //视频文件
file = "open " + Convert.ToChar(34) + file + Convert.ToChar(34) + " alias media";
mciSendString(file, buf, buf.Length, 0); //初始化音频文件
mciSendString("play media", buf, buf.Length, 0); //播放音频文件
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsFormsMedia
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{ } [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
); private void button1_Click(object sender, EventArgs e)
{
string buf = "";
buf = buf.PadLeft(128, ' ');
string file = @"F:\音乐\错错错.mp3"; //视频文件
file = "open " + Convert.ToChar(34) + file + Convert.ToChar(34) + " alias media";
mciSendString(file, buf, buf.Length, 0); //初始化音频文件
mciSendString("play media", buf, buf.Length, 0); //播放音频文件
}
}
}
群里看到的代码,一实验还真好使 本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/aspnet2002web/archive/2010/12/15/6078939.aspx
view plaincopy to clipboardprint?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsFormsMedia
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
[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
);
private void button1_Click(object sender, EventArgs e)
{
string buf = "";
buf = buf.PadLeft(128, ' ');
string file = @"F:\音乐\错错错.mp3"; //视频文件
file = "open " + Convert.ToChar(34) + file + Convert.ToChar(34) + " alias media";
mciSendString(file, buf, buf.Length, 0); //初始化音频文件
mciSendString("play media", buf, buf.Length, 0); //播放音频文件
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsFormsMedia
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{ } [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
); private void button1_Click(object sender, EventArgs e)
{
string buf = "";
buf = buf.PadLeft(128, ' ');
string file = @"F:\音乐\错错错.mp3"; //视频文件
file = "open " + Convert.ToChar(34) + file + Convert.ToChar(34) + " alias media";
mciSendString(file, buf, buf.Length, 0); //初始化音频文件
mciSendString("play media", buf, buf.Length, 0); //播放音频文件
}
}
}
群里看到的代码,一实验还真好使 本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/aspnet2002web/archive/2010/12/15/6078939.aspx
.NET播放音乐 - さびしい.Net/Java技术与技巧 - CSDN博客
精妙SQL语句收集 - さびしい.Net/Java技术与技巧 - CSDN博客
析构函数用于析构类的实例 - さびしい.Net/Java技术与技巧 - CSDN博客
面试必须要知道的SQL语法,语句 - さびしい.Net/Java技术与技巧 - CSDN博...
Session,ViewState用法 - さびしい.Net/Java技术与技巧 - CS...
2011年.NET面试题总结---献给即将找工作的同行们 - さびしい.Net/Java技...
敏捷软件开发11个原则 - (Java/C/Php/C /.NET) (OS,DB,Web,Net,Graph,Game) - CSDN博客
NET(C#)连接各类数据库-集锦 - .net - CSDN技术中心
Java JDK 5.0学习笔记 - 免费试读 - book.csdn.net
博客园 - 技术领先,管理至上 - 在.net平台上运行伪JAVA
JAVA客户端通过SOAP与NET的
Java与.NET开发的Web Services相互调用的技术。
CSDN技术中心 VS.NET 2003 控件命名规范
程序员如何营销自己? - 网眼技术@CSDN.NET - CSDNBlog
程序员如何营销自己? - 网眼技术@CSDN.NET - CSDNBlog
.NET求职技术总结 - Meazza-asp.net - 博客园
由Java说起:编程语言还需要开源吗? - CSDN.NET - CSDN软件研发频道
ChinaUnix.net - Java、Java Applet与 JavaScript间的通信
.NET 频道 - CSDN :由.NET专家提供给你的技术资源中心
如何保存SQL的money类型数据。 .NET技术 / VB.NET - CSDN社区 c...
程序员:提高编程效率的技巧 - CSDN.NET
community.java.net - Portlet
Java .Net 的区别
.net 和java发展前景