C# 实现播发器淡入淡出
要实现淡入淡出功能,有个listview里有歌曲和需要淡入淡出,切入切出的时间。然后实现淡入淡出,还有切入切出,一开始播放就播放歌曲的副歌部分,副歌放完立即停止播放。private void timer1_Tick(object sender, EventArgs e)
{
string t = DateTime.Now.ToLongTimeString().ToString();
this.textBox1.Text = t.ToString();
for (int i = 0; i < listView1.Items.Count; i++)
if (this.textBox1.Text == this.listView1.Items.SubItems[1].Text)
{
axWindowsMediaPlayer1.URL = listView1.Items.SubItems[3].Text;
axWindowsMediaPlayer1.Ctlcontrols.play();
// this.timer1.Enabled = false;
timer2.Enabled = true;
}
}
}
//下面想实现淡入淡出,根本不行啊
private void timer2_Tick_1(object sender, EventArgs e)
{
for (int x = 0; x < listView1.Items.Count; x++)
if (axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsPlaying)
{
if (axWindowsMediaPlayer1.settings.volume > 70)
axWindowsMediaPlayer1.settings.volume = axWindowsMediaPlayer1.settings.volume - 1;
if (axWindowsMediaPlayer1.settings.volume < 0)
axWindowsMediaPlayer1.settings.volume = axWindowsMediaPlayer1.settings.volume + 1;
timer2.Enabled =false ;
}
}
//下面想实现切入
private void timer3_Tick(object sender, EventArgs e)
{
for (int y= 0; y< listView1.Items.Count; y++)
if (listView1.Items[y].SubItems[4].Text != null)
if (axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsPlaying)
{
axWindowsMediaPlayer1.Ctlcontrols.currentPosition = Convert.ToDouble(listView1.Items[y].SubItems[4].Text);
timer3.Enabled = false;
timer4.Enabled = true;
}
}
private double ToDouble(string p)
{
throw new NotImplementedException();
}
//下面想实现切出
private void timer4_Tick(object sender, EventArgs e)
{
for (int z = 0; z < listView1.Items.Count; z++)
if (listView1.Items[z].SubItems[5].Text != null)
if (axWindowsMediaPlayer1.Ctlcontrols.currentPosition ==Convert .ToDouble ( listView1.Items[z].SubItems[5].Text))
{
axWindowsMediaPlayer1.Ctlcontrols.stop();
timer4.Enabled = false;
}