1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| public void Open(string sFileName)
{
if (!Opened)
{
Pcommand = "open \"" + sFileName + "\" type mpegvideo alias " + hnd;
if ((Err = mciSendString(Pcommand, null, 0, IntPtr.Zero)) != 0) OnError(new ErrorEventArgs(Err));
FName = sFileName;
Opened = true;
Playing = false;
Paused = false;
Pcommand = "set " + hnd + " time format milliseconds";
if ((Err = mciSendString(Pcommand, null, 0, IntPtr.Zero)) != 0) OnError(new ErrorEventArgs(Err));
Pcommand = "set " + hnd + " seek exactly on";
if ((Err = mciSendString(Pcommand, null, 0, IntPtr.Zero)) != 0) OnError(new ErrorEventArgs(Err));
CalculateLength();
OnOpenFile(new OpenFileEventArgs(sFileName));
}
else
{
this.Close();
this.Open(sFileName);
}
}
private void CalculateLength()
{
StringBuilder str = new StringBuilder(128);
Pcommand = "status " + hnd + " length";
if ((Err = mciSendString(Pcommand, str, 128, IntPtr.Zero)) != 0) OnError(new ErrorEventArgs(Err));
Lng = Convert.ToUInt64(str.ToString());
} |
Partager