Search code examples
c#visual-studiovlcsystem.diagnostics

How to stop a VLC player from another application?


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.


Solution

  • Process.Kill(); should do the trick.

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

    Reference: Process.Kill Method (MSDN).