所以我的学校阻止了Spotify,我们无法听音乐,所以我做了一个Mp3播放器。然而,在列表框中播放文件后,我无法让它自动播放下一个文件。我是C#的新手,所以我可能会慢慢接受。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Mp3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string[] files, paths;
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
axWindowsMediaPlayer1.URL = paths[listBox1.SelectedIndex];
}
private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() ==
System.Windows.Forms.DialogResult.OK)
{
files = openFileDialog1.SafeFileNames;
paths = openFileDialog1.FileNames;
for(int i=0; i< files.Length; i++)
{
listBox1.Items.Add(files[i]);
}
}
}
}
}
答案 0 :(得分:0)
我建议搜索一个告诉你播放器何时停止的方法,然后你可以在列表中选择下一个索引:
axWindowsMediaPlayer1.URL = paths[listBox1.SelectedIndex];
然后将此行传递给播放器:
Select a.*, b.*
From samp a
Left Outer Join samp2 b On b.rnum + 1 = a.rnum
Order by a.rnum;