How do I play the next song/video from the listBox automatically
the path is inside the listBox the problem is how do I get to play the song/video in it
Here is my code:
- namespace JustSingSystem
- {
- public partial class Karaoke : Form
- {
- MySqlConnection connection = new MySqlConnection("datasource=localhost;port=3306;username=root;password=seven7");
- MySqlCommand command;
- MySqlDataReader mdr;
- public Karaoke()
- {
- InitializeComponent();
- }
- private void button8_Click(object sender, EventArgs e)
- {
- try
- {
- connection.Open();
- string selectQuery = "SELECT * FROM justsing.songsinfo WHERE songnumber=" + int.Parse(textBox1.Text);
- command = new MySqlCommand(selectQuery, connection);
- mdr = command.ExecuteReader();
- if (mdr.Read())
- {
- textBox2.Text = mdr.GetString("song");
- textBox3.Text = mdr.GetString("song");
- }
- else
- {
- textBox2.Text = "";
- textBox1.Text = "";
- MessageBox.Show("No Data For This Id");
- }
- connection.Close();
- listBox1.Items.Add(this.textBox2.Text);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- private void button1_Click(object sender, EventArgs e)
- {
- SoundPlayer splayer = new SoundPlayer(@"C:\Users\Tocz\Desktop\Macromedia\test.wav");
- splayer.Play();
- }
- private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
- {
- }
- private void button13_Click(object sender, EventArgs e)
- {
- connection.Open();
- string selectQuery = "SELECT * FROM justsing.songsinfo WHERE songnumber=" + int.Parse(textBox1.Text);
- command = new MySqlCommand(selectQuery, connection);
- mdr = command.ExecuteReader();
- if (mdr.Read())
- {
- textBox2.Text = mdr.GetString("song");
- }
- else
- {
- textBox2.Text = "";
- textBox1.Text = "";
- MessageBox.Show("No Data For This Id");
- }
- connection.Close();
- axWindowsMediaPlayer1.URL = "" + textBox2.Text;
- }
- private void axWindowsMediaPlayer1_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
- {
- {
- if (axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsMediaEnded)
- {
- timer1.Interval = 100;
- timer1.Enabled = true;
- }
- }
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- string path = textBox2.Text;
- if (listBox1.SelectedIndex < path.Length - 1)
- {
- listBox1.SelectedIndex++;
- timer1.Enabled = false;
- axWindowsMediaPlayer1.Ctlcontrols.play();
- }
- else
- {
- listBox1.SelectedIndex = 0;
- timer1.Enabled = false;
- }
- }
- }
- }
Replies
Know the answer? Post it — somebody with the same question will find it here.