Rizwan Saleem

Rizwan Saleem

  • NA
  • 1
  • 2.1k

i want to play a video file from list box in media player.

Jun 16 2016 4:58 AM
i am working on windows form application and i want to play a video file in media player from list box.i get those video files from my project directory and kept in list box.the source code shows an error when i pass the URL to ax-media player that is "can not implicitly convert type object to string".how can i fix this or is there any other way to play that video.
here is the code
private void button1_Click(object sender, EventArgs e)
{
string path = @"abc";
foreach (string s in Directory.GetFiles(path, "*.mpeg4").Select(Path.GetFileName))
listBox1.Items.Add(s);
}
private void button2_Click(object sender, EventArgs e)
{
listBox1.SelectedItems.Clear();
for (int i = 0; i < listBox1.Items.Count; i++)
{
if (listBox1.Items[i].ToString().Contains(cmbox_tchr.SelectedItem.ToString()))
{
listBox1.SetSelected(i, true);
}
}
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
axWindowsMediaPlayer1.URL = listBox1.SelectedItem;
axWindowsMediaPlayer1.Ctlcontrols.play();
}
}
}
 

Answers (1)