急急急!最近自己写了个播放器用到了timer来控制进度条(tarckBar)问题。自己思考了不会做。下面是代码:就是红色部分,若不用timer1.Start()则播放正常,一用到timer1.start(),播放了几帧就直接跳到最后播放完毕那里了。请各位帮我看看呀。
private void tsmiOpenFile_Click(object sender, EventArgs e)
{
string filePath="";
OpenFileDialog fileDialog = new OpenFileDialog();
fileDialog.Filter = "MedioFile|*.264;*.dav;|AllFiles|*.*";
if (DialogResult.OK == fileDialog.ShowDialog())
filePath = fileDialog.FileName;
player.OpenFile(filePath);
lblMessage.Text = player.FiledMessage;
tbarPlay.Maximum = Convert.ToInt32(player.TotalTime.TotalSeconds);
tbarPlay.Minimum = 0;
tsmiCloseFrame.Enabled = true;
player.Play();
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
int tbrValue=Convert.ToInt32(player.PlayedTime.TotalSeconds);
if (player.PlayState != PlayStates.Stopped || player.PlayState != PlayStates.Paused)
{
if (tbrValue> tbarPlay.Maximum)
tbrValue = tbarPlay.Maximum;
if (tbrValue < tbarPlay.Minimum)
tbrValue = tbarPlay.Minimum;
tbarPlay.Value = tbrValue;
lblNowToTolelTime.Text = player.PlayedTime.ToString() + "/" + player.TotalTime.ToString();
lblNowToTotelFrame.Text = player.PlaydeFrameNumber.ToString() + "/" + player.TotalFrame.ToString();
}
}