namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string[] nomi, percorsi; //nomi means names and percorsi means paths. I'm italian, that's why
private void apri_Click(object sender, EventArgs e)
{
OpenFileDialog apri = new OpenFileDialog();
apri.Filter = "File *.mp3|*.mp3";
apri.Multiselect = true;
DialogResult scelta = apri.ShowDialog();
if (scelta == DialogResult.OK)
{
nomi = apri.SafeFileNames;
percorsi = apri.FileNames;
for (int i = 0; i < nomi.Length; i++)
Files.Items.Add(nomi[i]);
}
}
private void Files_SelectedIndexChanged(object sender, EventArgs e)
{
player.URL = percorsi[Files.SelectedIndex];
}
}
}
我有这个代码来创建一个简单的MP3播放器。是否有方便启用媒体播放器上的上一个/下一个按钮并播放列表框中的下一首/上一首歌?还有一种方法可以找到这首歌的结尾,以便我可以播放下一首歌吗?提前谢谢!
答案 0 :(得分:0)
private void player_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
{
if (e.newState == 8)
{
}
}
找到解决方案。我发布它可能会帮助别人。如果歌曲结束,e.newState == 8为真,那么我就可以开始播放下一首歌了。