我正在使用WMPLib在C#中制作一个简单的mp3player。我已经差不多完成了,但我还有一件事要做。
我想知道这首歌已经走了多远,还有这首歌还剩下多少。例如,使用进度条。
谢谢
亚当
发布于 2011-12-19 09:51:12
private void timer1_Tick(object sender, EventArgs e)
{
double percent = 0;
if (mp.Length != 0)
percent = ((double) wplayer.controls.currentPosition / wplayer.controls.currentItem.duration);
progressBar1.Value = (int)(percent * progressBar1.Maximum);
}发布于 2015-01-23 10:20:46
我有一个想法,只要试着在你的项目表单中添加statusStrip,然后添加一个ToolStripStatusLabel和ToolStripProgressBar,然后你就可以使用这个简单的代码了,它100%有效:
public void Sound_Progress(ToolStripStatusLabel l1, ToolStripProgressBar psb)
{
//NASSIM LOUCHANI
int i = Convert.ToInt32(Player.controls.currentItem.duration);
int j = Convert.ToInt32(Player.controls.currentPosition);
int Defrence = (i-j);
l1.Text = Player.controls.currentPositionString + " | " + Player.controls.currentItem.durationString;
psb.Maximum = i;
psb.Minimum = 0;
if (Defrence == i)
psb.Value = i;
else if (Defrence != i)
psb.Value = Defrence;
else if (Defrence == 0)
l1.Text = "";
}别忘了在你的项目窗体中添加一个计时器,并将Sound_Progress(你的ToolStripStatusLabel,你的ToolStripProgressBar)放入你的Timer_Tick()事件中。
谢谢!
https://stackoverflow.com/questions/1876224
复制相似问题