问题
Is there a way to stop a video at a particular position using Windows Media Player SDK? I am using C# for embedding the player and trying to see if the IWMPControls3 Interface has any stopping capability at a particular point in terms of position or time. If it can be done, then how to do it?
回答1:
It certainly can be done, though I no longer remember the techniques. There are ways that you can access the data in the stream well enough to reconstruct the audio and individual frames of video. People have written systems where the user can type a precise time and frame number and the video player jumps to that spot.
Since your question was "is there a way", the answer is "Yes". However, I can't remember enough of the specifics to tell you how to do it.
回答2:
Like I explained in the same question here, you can use a timer to control the CurrentPosition:
private Timer tmrWmpPlayerPosition;
private TimeSpan StopPosition;
private void btn_Click(object sender, EventArgs e)
{
wmpPlayer.Ctlcontrols.currentPosition = 4;
StopPosition=TimeSpan.Parse("00:20:20");
StopWmpPlayerTimer();
StartWmpPlayerTimer();
}
private void tmrWmpPlayerPosition_Tick(object sender, EventArgs e)
{
if ((Convert.ToInt32(StopPosition.TotalSeconds) != Convert.ToInt32(wmpPlayer.Ctlcontrols.currentPosition))) return;
wmpPlayer.Ctlcontrols.pause();
StopWmpPlayerTimer();
}
private void StartWmpPlayerTimer()
{
tmrWmpPlayerPosition = new Timer();
tmrWmpPlayerPosition.Tick += new EventHandler(tmrWmpPlayerPosition_Tick);
tmrWmpPlayerPosition.Enabled = true;
tmrWmpPlayerPosition.Interval = 1000;
tmrWmpPlayerPosition.Start();
}
private void StopWmpPlayerTimer()
{
if (tmrWmpPlayerPosition != null)
tmrWmpPlayerPosition.Dispose();
tmrWmpPlayerPosition = null;
}
来源:https://stackoverflow.com/questions/1138682/stop-video-at-specific-position-using-windows-media-player-sdk