/// <summary> /// 播放快进(每次快进 FramesStep) /// </summary> public void Forward() { int err = 0; StringBuilder buf = new StringBuilder(1000); TimeFormat tf = timeFormat; if (deviceID > 0) { if ((devCaps & DevCaps.CanShowVideo) == DevCaps.CanShowVideo) { if (GetLength() - GetPosition() <= framesStep) { MCI_GENERIC_PARMS gen = new MCI_GENERIC_PARMS(); Pause(); err = mciSendCommandA(deviceID, MCI_SEEK, MCI_SEEK_TO_END | MCI_WAIT, ref gen); if (err != 0) { mciGetErrorStringA(err, buf, 1000); //throw new ApplicationException(buf.ToString()); } Play(); } else { MCI_DGV_STEP_PARMS step = new MCI_DGV_STEP_PARMS(); Pause(); if (timeFormat != TimeFormat.Frames) { timeFormat = TimeFormat.Frames; MciSet(0, MCI_FORMAT_FRAMES, MCI_SET_TIME_FORMAT); } step.dwFrames = framesStep; err = mciSendCommandA(deviceID, MCI_STEP, MCI_WAIT | MCI_DGV_STEP_FRAMES, ref step); if (err != 0) { mciGetErrorStringA(err, buf, 1000); //throw new ApplicationException(buf.ToString()); } if (tf != TimeFormat.Frames) { timeFormat = tf; MciSet(0, (int)tf, MCI_SET_TIME_FORMAT); } Play(); } } else { if (timeFormat != TimeFormat.MilliSeconds) { timeFormat = TimeFormat.MilliSeconds; MciSet(0, MCI_FORMAT_MILLISECONDS, MCI_SET_TIME_FORMAT); } SeekToAny(GetPosition() + framesStep); if (tf != TimeFormat.MilliSeconds) { timeFormat = tf; MciSet(0, (int)tf, MCI_SET_TIME_FORMAT); } } } }
private static extern int mciSendCommandA( Int32 wDeviceID, UInt32 uMessage, Int32 dwParam, ref MCI_DGV_STEP_PARMS Any);