Control VLC from another Programm

Microsoft Windows specific usage questions
Forum rules
Please post only Windows specific questions in this forum category. If you don't know where to post, please read the different forums' rules. Thanks.
CaptainIglo
Blank Cone
Blank Cone
Posts: 16
Joined: 07 Jan 2007 18:48

Control VLC from another Programm

Postby CaptainIglo » 11 Jan 2007 09:19

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

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Postby Jean-Baptiste Kempf » 11 Jan 2007 18:35

Use the ActiveX interface.
Or if your program is GPL, use the .Net interface.
http://wiki.videolan.org/.Net_Interface_to_VLC
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

CaptainIglo
Blank Cone
Blank Cone
Posts: 16
Joined: 07 Jan 2007 18:48

Postby CaptainIglo » 12 Jan 2007 02:02

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

Tappen
Cone that earned his stripes
Cone that earned his stripes
Posts: 150
Joined: 30 Oct 2006 07:55

Postby Tappen » 12 Jan 2007 02:16

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.

CaptainIglo
Blank Cone
Blank Cone
Posts: 16
Joined: 07 Jan 2007 18:48

Postby CaptainIglo » 12 Jan 2007 02:27

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

inschenjoer
New Cone
New Cone
Posts: 4
Joined: 12 Jan 2007 14:43
Contact:

Postby inschenjoer » 12 Jan 2007 14:46

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

CaptainIglo
Blank Cone
Blank Cone
Posts: 16
Joined: 07 Jan 2007 18:48

Postby CaptainIglo » 12 Jan 2007 14:57

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.

inschenjoer
New Cone
New Cone
Posts: 4
Joined: 12 Jan 2007 14:43
Contact:

Postby inschenjoer » 12 Jan 2007 15:39

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

CaptainIglo
Blank Cone
Blank Cone
Posts: 16
Joined: 07 Jan 2007 18:48

Postby CaptainIglo » 12 Jan 2007 15:45

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

Tappen
Cone that earned his stripes
Cone that earned his stripes
Posts: 150
Joined: 30 Oct 2006 07:55

Postby Tappen » 12 Jan 2007 22:49

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.

CaptainIglo
Blank Cone
Blank Cone
Posts: 16
Joined: 07 Jan 2007 18:48

Postby CaptainIglo » 13 Jan 2007 08:33

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?

inschenjoer
New Cone
New Cone
Posts: 4
Joined: 12 Jan 2007 14:43
Contact:

Postby inschenjoer » 13 Jan 2007 13:12

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

CaptainIglo
Blank Cone
Blank Cone
Posts: 16
Joined: 07 Jan 2007 18:48

Postby CaptainIglo » 13 Jan 2007 17:54

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...

Tappen
Cone that earned his stripes
Cone that earned his stripes
Posts: 150
Joined: 30 Oct 2006 07:55

Postby Tappen » 17 Jan 2007 00:49

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.

CaptainIglo
Blank Cone
Blank Cone
Posts: 16
Joined: 07 Jan 2007 18:48

Postby CaptainIglo » 17 Jan 2007 08:13

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)...

Tappen
Cone that earned his stripes
Cone that earned his stripes
Posts: 150
Joined: 30 Oct 2006 07:55

Postby Tappen » 17 Jan 2007 19:48

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.

inschenjoer
New Cone
New Cone
Posts: 4
Joined: 12 Jan 2007 14:43
Contact:

Postby inschenjoer » 01 Mar 2007 20:29

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


Return to “VLC media player for Windows Troubleshooting”

Who is online

Users browsing this forum: No registered users and 44 guests