如何播放音频文件(avi,mp3等)??

Cango 2003-08-29 03:44:14
UP
...全文
43 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
qinb 2003-08-29
  • 打赏
  • 举报
回复
direct90sdk中有实例,从微软下吧
panyee 2003-08-29
  • 打赏
  • 举报
回复
最简单的方法就是直接把媒体播放器的控件拖到窗体上来,
雪狼1234567 2003-08-29
  • 打赏
  • 举报
回复
这儿有源码?
http://www.codeguru.com/cs_graphics/WavPlay.html
雪狼1234567 2003-08-29
  • 打赏
  • 举报
回复
public class Form1 : System.Windows.Forms.Form
{
double shu;
double temps1;
double temps2;
double jg;
double save;
double zf;
string js;
bool gl;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button button5;
private System.Windows.Forms.Button button6;
private System.Windows.Forms.Button button7;
private System.Windows.Forms.Button button8;
private System.Windows.Forms.Button button9;
private System.Windows.Forms.Button button10;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Button button11;
private System.Windows.Forms.Button button12;
private System.Windows.Forms.Button button13;
private System.Windows.Forms.Button button14;
private System.Windows.Forms.Button button15;
private System.Windows.Forms.Button button16;
private System.Windows.Forms.Button button17;
private System.Windows.Forms.Button button18;
private System.Windows.Forms.Button button19;
private System.Windows.Forms.Button button20;
private System.Windows.Forms.Button button21;
private System.Windows.Forms.Button button22;
private System.Windows.Forms.Button button23;

[DllImport("winmm.dll", EntryPoint="PlaySound")]
public static extern bool PlaySound(ref Byte snd, IntPtr hmod, uint fdwSound);

[DllImport("winmm.dll", EntryPoint="PlaySound")]
public static extern int PlaySound(string lpszName,int hModule,int dwFlags);

public enum PlayingFlags :uint
{
SND_SYNC = 0x00,
SND_ASYNC = 0x01,
SND_NODEFAULT = 0x02,
SND_MEMORY = 0x04,
SND_ALIAS = 0x010000,
SND_FILENAME = 0x020000,
SND_RESOURCE = 0x040004,
SND_ALIAS_ID = 0x0110000,
SND_ALIAS_START = 0,
SND_LOOP = 0x08,
SND_NOSTOP = 0x010,
SND_VALID = 0x01F,
SND_NOWAIT = 0x02000,
SND_PURGE = 0x40
}
...................................................省略
private void button1_Click(object sender, System.EventArgs e)
{
Form1.PlaySound(filename.wav,0,(int)Form1.PlayingFlags.SND_SYNC);
Button btn=(Button) sender;
if (gl)
{
textBox1.Text=btn.Text;
gl=false;
}
else if (textBox1.Text=="0")
{
textBox1.Text=btn.Text;
gl=false;
}
else
{
textBox1.Text=textBox1.Text+btn.Text;
gl=false;
}
shu = Convert.ToDouble(textBox1.Text);
}
ivsee 2003-08-29
  • 打赏
  • 举报
回复
看看这个了

using System;
using System.Runtime.InteropServices;

class musicplay{
[DllImport("winmm.dll")]
private static extern long mciSendString(string lpstrCommand,string lpstrReturnString,long length,long hwndcallback);
public musicplay(string name){
filename=name;
}
public void play(){
t=mciSendString(@"open " + filename,m,0,0);
t=mciSendString(@"play " + filename + @" wait",m,0,0);
t=mciSendString(@"close " + filename,m,0,0);
}
private string filename;
private string m=@" ";
private long t;
}

class test{
static void Main(){
Console.WriteLine("请输入你要播放的歌曲的路径");
musicplay mpl=new musicplay(Console.ReadLine());
mpl.play();
Console.WriteLine("播放完毕,再见");

}
}
速马 2003-08-29
  • 打赏
  • 举报
回复
好像可以用WMP的SDK
BeyondLove2000 2003-08-29
  • 打赏
  • 举报
回复
directX9.0
Cango 2003-08-29
  • 打赏
  • 举报
回复
有人会的吗?
janus1999 2003-08-29
  • 打赏
  • 举报
回复
up

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧