2

My application needs to keep track of what videos were played in VLC and their progress in the progress bar.

Preferable, it would be best to collect the information if VLC is already running rather than having to restart it with command line variables.

I tried to use the console, but it does not read all of the console output and none of the commands work when written into the input stream.

Process p;

p = new Process();
p.StartInfo.FileName = @"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe";
p.StartInfo.Arguments = "\"C:\\mymovie.mp4\"";

p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;

p.OutputDataReceived += (sender2, e2) =>
{
    if (e2.Data != null)
    {
        Log("Received output data: " + e2.Data);
    }
    else
        Log("Received output data: NULL");
};

p.ErrorDataReceived += (sender2, e2) =>
{
    if (e2.Data != null)
    {
        Log("Received Error data: " + e2.Data);
    }
    else
        Log("Received Error data: NULL");
};

p.Start();

p.BeginOutputReadLine();
p.BeginErrorReadLine();

p.StandardInput.WriteLine("get_time");
p.StandardInput.Flush();

So then I tried to use the remote control API via sockets.

IPEndPoint socketAddress = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 54165);
var vlcServerProcess = Process.Start(@"-I rc --rc-host " + socketAddress.ToString());

However, this method opens up a console window that I don't want visible and plays the video without any of the GUI controls. Just a d3d window.

I need it to look and behave completely normal if that is possible through this method.

Is there any other simple method I can do to get the current playing file name and progress without having to write a VLC plugin or read the process's memory?

Cœur
  • 37,241
  • 25
  • 195
  • 267
John
  • 5,942
  • 3
  • 42
  • 79
  • This seems like a similar question to: https://stackoverflow.com/questions/7382793/does-vlc-media-player-have-a-c-sharp-interface – MattValerio Dec 26 '19 at 05:16
  • No it's not, the link you sent is about using vlc libraries in a C# program, the original question is about CONTROLLING vlc from a C# application via the remote control port opened up when starting vlc with the "rc" command line argument(s). – LordWabbit Aug 05 '20 at 22:20

1 Answers1

1

I have also been trying to get this working, I managed to send basic commands which return no result (rewind etc.) but as soon as I tried to receive data I ran into problems.
UNTIL I found this...

https://gist.github.com/SamSaffron/101357

Some tweaking of the command line arguments when starting vlc - I changed them to

--extraintf="rc" --rc-host="localhost:8812"

was needed, but I still get the command console (although I can't enter commands via that for some reason) also the buffering seems slightly wonky, but it just may be due to me and not the source code. It does however do mostly what I need at this time.

Dharman
  • 30,962
  • 25
  • 85
  • 135
LordWabbit
  • 147
  • 5
  • I've recently tried to make another remote controller for VLC and I ended up controlling it and getting the progress using the web interface method and http requests. – John Aug 06 '20 at 00:38