//播放 public void play() { TemStr = ""; TemStr = TemStr.PadLeft(127, Convert.ToChar(" ")); APIClass.mciSendString("play media", TemStr, TemStr.Length, 0); mediaPlayer.state = State.mPlaying; }
public void Pause() { TemStr = ""; TemStr = TemStr.PadLeft(128, Convert.ToChar(" ")); ilong = APIClass.mciSendString("pause media", TemStr, TemStr.Length, 0); mediaPlayer.state = State.mPuase; }
//停止 public void Stop() { TemStr = ""; TemStr = TemStr.PadLeft(128, Convert.ToChar(" ")); ilong = APIClass.mciSendString("close media", TemStr, 128, 0); ilong = APIClass.mciSendString("close all", TemStr, 128, 0); mediaPlayer.state = State.mStop; if (mediaPlayer.iName.Equals(tmpPath)) { File.Delete(tmpPath); } }
private void init(string path) { try { TemStr = ""; TemStr = TemStr.PadLeft(127, Convert.ToChar(" ")); Name = Name.PadLeft(260, Convert.ToChar(" ")); mediaPlayer.iName = path; ilong = APIClass.GetShortPathName(mediaPlayer.iName, Name, Name.Length); Name = GetCurrPath(Name); Name = "open " + Convert.ToChar(34) + Name + Convert.ToChar(34) + " alias media"; ilong = APIClass.mciSendString("close all", TemStr, TemStr.Length, 0); ilong = APIClass.mciSendString(Name, TemStr, TemStr.Length, 0); ilong = APIClass.mciSendString("set media time format milliseconds", TemStr, TemStr.Length, 0); mediaPlayer.state = State.mStop; } catch (Exception ex) { MessageBox.Show(ex.Message); } }