How to stop a VLC player from another application?

1k views Asked by At

I have started the VLC player in my application using this code:

Process.Start("C://Program Files//Videolan//VLC//VLC.exe", "\"rtsp://xxx.xxx.xx.xx:554/h264\" --qt-start-minimized --sout=#transcode{vcodec=theo,vb=800,acodec=flac,ab=128,channels=2,samplerate=44100}:file{dst=C:\\123.ogg,no-overwrite}");

Now I need to stop/close this. Please advice.

2

There are 2 answers

0
OnoSendai On BEST ANSWER

Process.Kill(); should do the trick.

A somewhat gentler way would be Process.CloseMainWindow, but depends on implementation.

Reference: Process.Kill Method (MSDN).

7
Durai On

You can kill by using the following code

try
{   
    foreach (Process proc in Process.GetProcessesByName("processname"))
    {
        proc.Kill();
    }
}
catch(Exception ex)
{

}