新闻中心

EEPW首页 > 消费电子 > 设计应用 > C#中用API实现MP3等音频文件的播放类

C#中用API实现MP3等音频文件的播放类

作者:时间:2009-06-15来源:网络收藏

public void StopT()

{

  TemStr = ;

  TemStr = TemStr.PadLeft(128,Convert.ToChar( ));

  ilong = Class.mciSendString(close media, TemStr, 128, 0);

  ilong = Class.mciSendString(close all, TemStr, 128, 0);

  mc.state = State.mStop ;

}

public void Puase()

{

  TemStr = ;

  TemS

tr = TemStr.PadLeft(128,Convert.ToChar( ));

  ilong = Class.mciSendString(pause media, TemStr, TemStr.Length, 0);

  mc.state = State.mPuase ;

}

private string GetCurrPath(string name)

{

  if(name.Length 1) return ;

  name = name.Trim();

  name = name.Substring(0,name.Length-1);

  return name;

}

//总时间

public int Duration

{

  get

  {

durLength = ;

durLength = durLength.PadLeft(128,Convert.ToChar( )) ;

APIClass.mciSendString(status media length, durLength, durLength.Length, 0);

durLength = durLength.Trim();

if(durLength == ) return 0;

return (int)(Convert.ToDouble(durLength) / 1000f);

  }

}

//当前时间

public int CurrentPosition

{

  get

  {

durLength = ;

durLength = durLength.PadLeft(128,Convert.ToChar( )) ;

APIClass.mciSendString(status media position, durLength, durLength.Length, 0);

mc.iPos = (int)(Convert.ToDouble(durLength) / 1000f);

return mc.iPos;

  }

}

  }

  public class APIClass

  {

[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

);

  }

}


上一页 1 2 下一页

评论


相关推荐

技术专区

关闭