1个回答
展开全部
/// <summary>
/// 播放下首或上首
/// </summary>
/// <param name="flag">为true则为下首</param>
private void PlayPrevOrNext(bool flag=true)
{
if (flag)//下首
{
if (listBox1.SelectedIndex == listBox1.Items.Count - 1) listBox1.SelectedIndex = 0;//如已为最后,则跳转至第一首
else listBox1.SelectedIndex++;
}
else
if (listBox1.SelectedIndex == 0) listBox1.SelectedIndex = listBox1.Items.Count - 1;//如为第一首,则跳转至最后一首
else listBox1.SelectedIndex--;
axWindowsMediaPlayer1.Ctlcontrols.stop();
axWindowsMediaPlayer1.URL = listBox1.SelectedItem.ToString();
axWindowsMediaPlayer1.Ctlcontrols.play();
}
下一首就是PlayPrevOrNext();上一首就是PlayPrevOrNext(false)
/// 播放下首或上首
/// </summary>
/// <param name="flag">为true则为下首</param>
private void PlayPrevOrNext(bool flag=true)
{
if (flag)//下首
{
if (listBox1.SelectedIndex == listBox1.Items.Count - 1) listBox1.SelectedIndex = 0;//如已为最后,则跳转至第一首
else listBox1.SelectedIndex++;
}
else
if (listBox1.SelectedIndex == 0) listBox1.SelectedIndex = listBox1.Items.Count - 1;//如为第一首,则跳转至最后一首
else listBox1.SelectedIndex--;
axWindowsMediaPlayer1.Ctlcontrols.stop();
axWindowsMediaPlayer1.URL = listBox1.SelectedItem.ToString();
axWindowsMediaPlayer1.Ctlcontrols.play();
}
下一首就是PlayPrevOrNext();上一首就是PlayPrevOrNext(false)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询