Page 1 of 1

Control VLC from another Programm

Posted: 11 Jan 2007 09:19
by CaptainIglo
Hi,

I'm currently using vlc.exe for Videostreaming in my program written in C#/.net.
I start the vlc.exe with the parameters that it streams the video (works!) and starts in the rc-mode (Command promt) und try to Redirect the StandardInput and -Output to my program.
I did'nt got any exception but the Output is still in the command promt and if I wrote something into the Input nothing happend.

So my Question:
How could i control vlc.exe from my programm?
Or is there a way to include vlc directly into my program?

greets
Capt.Iglo

Posted: 11 Jan 2007 18:35
by Jean-Baptiste Kempf
Use the ActiveX interface.
Or if your program is GPL, use the .Net interface.
http://wiki.videolan.org/.Net_Interface_to_VLC

Posted: 12 Jan 2007 02:02
by CaptainIglo
Sounds nice, but i did'nt get anything to work.
I've included all files in my project an could compile it successfully but if i try to play a file with the following code:

int id = vlcControl.AddToPlayList(@"C:\robots.avi", "Robots", null);
vlcControl.PlayItem(id);

nothing happend and i also have no idea how I could stream with that class.

Please help me, I need to stream a Video with .net.

greets
Capt.Iglo

Posted: 12 Jan 2007 02:16
by Tappen
I wrote a C# UserControl that wraps VLC, you might give it a try:

http://wiki.videolan.org/.Net_Interface_to_VLC

It also supports use as an ActiveX control but you don't need to do that from a C# program: it will work with no registration as long as you have the libvlc.dll and plugins directory from a VLC install in your own program's install directory.

Posted: 12 Jan 2007 02:27
by CaptainIglo
I'm already trying with your Control (j-b had posted it 2 post before) and it looks good, but I did'nt get anything to work.

I've tryed to play a file with the code as shown 1 post befor yours, but nothing happend and how could i give the vlc parameters to stream in your control?

greets
Capt.Iglo

Posted: 12 Jan 2007 14:46
by inschenjoer
Hello,

I'm trying the .Net Interface to VLC. And I can play a video with it. Is it possible to paint on top of the video?

Does this also work with mono under linux?

bye
Sebastian

Posted: 12 Jan 2007 14:57
by CaptainIglo
I'm trying the .Net Interface to VLC. And I can play a video with it.
Could you, please post your code, that I could look, where I did something wrong?
Is it possible to paint on top of the video?
Draw into a transparent Panel an set it exactly ofer the video.

Posted: 12 Jan 2007 15:39
by inschenjoer
I'm trying the .Net Interface to VLC. And I can play a video with it.
Could you, please post your code, that I could look, where I did something wrong?
You did not do something wrong, because it works fine. I will try the transparent window.

bye
Sebastian

Posted: 12 Jan 2007 15:45
by CaptainIglo
You did not do something wrong, because it works fine. I will try the transparent window.

bye
Sebastian
I'm also trying to use the class, but i could not play anything!
Please post your code so that I could compare it to mine.

greets
Capt.Iglo

Posted: 12 Jan 2007 22:49
by Tappen
CaptainIglo, just be sure to get all the latest files (except the .snk file, you don't need to sign or register the dll if you're calling it from C#) and create the VLanControl.dll. Then create a new Windows Application project, reference VLanControl, and drop a VlcUserControl onto your main form. Override OnLoad on the form and in that function you should be able to call AddToPlayList and then PlayItem with the id returned.

Oh and be sure you have libvlc.dll and the Plugins directory from VLC in the bin/Debug directory of the Windows Application project you create. That's where you'll be running from under Visual Studio.

If you want an overlay on top of this, you need to create a 2nd form. Set its TransparencyKey to Black, the BackColor to Black, ShowIcon and ShowInTaskbar to false. In the constructor of this 2nd form add the code
SetStyle(ControlStyles.ResizeRedraw, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
and UpdateStyles();
after InitializeComponent() in the contructor. Override OnPaint(). Anything you draw that isn't black will be visible.

Now create an instance of the 2nd form from your main form and set it's Owner to be the main form. Size, Position and Show it. You have a transparent overlay on top of the VLC window.

Posted: 13 Jan 2007 08:33
by CaptainIglo
Now i have donloaded the newes vlc and your files an coded the following:

Code: Select all

int id = vlcUserCtr.AddToPlayList(@"C:\robots.avi", "Robots", null); vlcUserCtr.PlayItem(id);
but nothing happend.

But if i add the vlcUserControl to my form i got an Error as shown:
Image
In English: Error by the generating the code for the Volume Propertie. Error: The Propertieaccessor Volume for the vlcUserctr-object has the folowing exception: The DLL libvlc: Die module was not found (Exception of HRESULT: 0x8007007E) xould not be loaded.

But i have the libvlc.dll and the plugin directory in every folder of the project copied...

2nd Question:
How could I give your control parameters so that the vlc will stream a file to network?

Posted: 13 Jan 2007 13:12
by inschenjoer
I also get this error. But when I run the program everything works fine. I also added the vlc control to my form. And in the mainform.load function I called AddAndPlay.

bye
Sebastian

Posted: 13 Jan 2007 17:54
by CaptainIglo
Didn't got anything working with your .net-Interface, sorry.

Now i had used the Interface from the following project:
http://dhost.info/xaudio/vlcenc.html
and this works very fine for me, because I only need to stream and not to play...

Posted: 17 Jan 2007 00:49
by Tappen
libvlc.dll and the plugins directory need to be in bin/Debug (or bin/Release if you're running a release build). Putting them in the directory with the source files doesn't work.

I'll look at the problem with the Volume property. It probably should be disabled in Design mode, that is, made not Browsable, since it can't be set until the control is loaded and Vlc is initialized. I didn't detect this problem in my own project since I create the control dynamically.

Posted: 17 Jan 2007 08:13
by CaptainIglo
libvlc.dll and the plugins directory need to be in bin/Debug (or bin/Release if you're running a release build). Putting them in the directory with the source files doesn't work.
libvlc.dll & plugins are in the debug AND source-file folder, but it didn't work.

The class from the link above works perfektly for me (I didn't need to play, only to stream)...

Posted: 17 Jan 2007 19:48
by Tappen
I updated VlcUserControl.cs on the wiki with some attributes that make the control better at being dropped on forms. It was trying to write to Vlc while in Design mode which wasn't good.

Posted: 01 Mar 2007 20:29
by inschenjoer
Hello,

I tried this and it works quiet good.
If you want an overlay on top of this, you need to create a 2nd form. Set its TransparencyKey to Black, the BackColor to Black, ShowIcon and ShowInTaskbar to false. In the constructor of this 2nd form add the code
SetStyle(ControlStyles.ResizeRedraw, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
and UpdateStyles();
after InitializeComponent() in the contructor. Override OnPaint(). Anything you draw that isn't black will be visible.

Now create an instance of the 2nd form from your main form and set it's Owner to be the main form. Size, Position and Show it. You have a transparent overlay on top of the VLC window.
But now I want to have the MouseMove, MouseDown and MouseUp-Event from the overlay-window or the videolan-control.

The events from the overlay-windows only fired when I enter areas, where I paint something. But I want it to fire everywhere. How can I do this?

bye
Sebastian