0

I am hoping someone can help me, i want to play another video file, however when i double click another video file it doesnt play it and just shows the last frame from the first video file. i am not sure what i am doing wrong.

below is my code

void listBox1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
string final = "file path";
playfile(final);
}
void playfile(string final)
        {
            var control = new VlcControl();
            var currentAssembly = Assembly.GetEntryAssembly();
            var currentDirectory = new FileInfo(currentAssembly.Location).DirectoryName;
            // Default installation path of VideoLAN.LibVLC.Windows
            var libDirectory = new DirectoryInfo(Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64"));
            control.BeginInit();
            control.VlcLibDirectory = libDirectory;
            control.Dock = DockStyle.Fill;
            control.EndInit();
            panel1.Controls.Add(control);
            control.ResetMedia();
            control.Play(new Uri(final).AbsoluteUri);

        }

i have tried things like

control.Dispose();
control.ResetMedia();
control.Update();
control.Refresh();

i have even tried to manipulate the panel however that didnt work

Thank you

Vijay Yadav
  • 91
  • 13

2 Answers2

0

seems as if i did not clear the panel correctly if anyone is having trouble with the same issue i used this

panel1.Controls.Clear();
panel1.Update();
panel1.Refresh();
Vijay Yadav
  • 91
  • 13
0

You don't need to destroy/add a new control each time. You could use the same player and just use

control.Play(newMedia);
cube45
  • 3,429
  • 2
  • 24
  • 35