Page 2 of 4

Posted: 12 Jan 2007 10:31
by Jean-Baptiste Kempf
The Test.html file has been renamed on the Wiki to .Net_Test.html.

Posted: 12 Jan 2007 18:24
by divx118
:D Thanks Tappen I will try it over the weekend

EDIT: I coudn't wait so I tried it.
my steps:
Build the dll file and create the snk no problem
copied both files to my vlc installation folder next to the libvlc.dll in
F:\Video tools\VLC\

Then i run regasm "F:\Video tools\VLC\VLanControl.dll" /codebase Types registered successfully

copied the Test.html to the folder and ran it. The object loads but i get no video just a white background (btw edited the html file to play a video of mine)

Update: It works for the no videopart. I added an onload event in the body tag to start playing the video. And that worked :D

I am running out of luck again I can't get it to show up in media center it just gives me a red cross, maybe it is because it is written in .Net 2 and media center is based on .NET 1.
In ie7 it just works fine.




PS I am using ie7 on a windowsXP media center machine.
Thanks alot for making this dll compatible with javascript :D


Maurice

Posted: 15 Jan 2007 10:51
by osmanosman
You are the best Tappen :P

Sizing Window to Native Video Size

Posted: 15 Jan 2007 23:02
by sgross
Tappen, Thank you for all your help!

I still have an issue with the sizing though and some of the properties...

I try sizing the window by the following code:

Code: Select all

VideoCtrlDataSet.StreamSourcesRow myStream; public ViewVideo(VideoCtrlDataSet.StreamSourcesRow aStream) { InitializeComponent(); myStream = aStream; } private void ViewVideo_Load(object sender, EventArgs e) { vlcVideo.AddToPlayList("udp://@" + myStream.MulticastIP + ":" + myStream.Port, "", null); vlcVideo.Play(); //MessageBox.Show(vlcVideo.VideoSize.Height.ToString()); this.Size = vlcVideo.VideoSize; this.Text = "Height: " + this.Size.Height + " Width: " + this.Size.Width; }


When this is run, it sizes the window to 0,0. If I uncomment the MessegeBox, the Text in the MessageBox is 0. Then the window loads the correct value (although it's a little wider than it should be, but I can deal with that).

I would think it cause the video hasn't fully "started to play" so it still reads the size as 0,0. But when stepping through in the debugger, it shows vlcVideo.VideoSize.Height as the right size, but just does not assign it to the local VideoSize.

Any ideas?

Also on another note, the inital properties

Code: Select all

this.vlcVideo.AllowVideoAdjustments = false; this.vlcVideo.Volume = 50;
cause the "trying to read from protected memory issue as if it's not being initialized correctly. Once I comment these lines out, it works fine.

Please let me know if you have ideas about either of these topics. Thank you.

Howto initalize NativeLibVlc

Posted: 16 Jan 2007 21:33
by Ncd
be sure you call Initialize() on the NativeLibVlc object before making any other calls to it.
I'm probably missing something basic here, but could anyone explain how to initalize the NativeLibVlc-object? Compiling the DLL is no problem, I can add the user control to a form, but where to go next?

Keep reading about OnLoad etc, but since the NativeLibVlc object appear to be protected, how do I initialize it?

Perhaps someone would be as kind as to post a working example?

Posted: 16 Jan 2007 23:15
by zbe
Tappen,

have you seen that :

http://wiki.videolan.org/MediaControlAPI#Full_API

How can you get informations about current playlist ?

Posted: 17 Jan 2007 00:16
by Tappen
Note: The .Net_Test.html file loads a file from my local hard-disk named Kiki.mpg as its sample. This obviously won't work for anyone but me so be sure to edit it before trying. Just change the filename to a short video of your own.

I just updated the .Net Wiki Page with a new VlcUserControl.cs file that makes all the Vlc native properties non-browsable so the control will work better in Design mode. Sorry about that, I created the control dynamically in my own code and never tried actually dropping it on a Form.

Ncd, if you built the whole DLL and dropped a VlcUserControl on your form or Web Page then VlcUserControl does the initialization of NativeLibVlc for you in its OnLoad. The only thing you need to worry about is not adding things to the playlist until your Form's OnLoad or later. The ambiguity is that I had the idea some people would only use the NativeLibVlc class and others would use the whole VlcUserControl and my documentation isn't too clear at explaining which case it's talking about.

sgross and others, your problem is that VLC is asynchronous. You might think you're loading the video when you call AddToPlaylist but actually this happens some time later in another thread within VLC. You can see in the test html file that I poll every second waiting for the State of the control to become Playing before I start playing around with the options, like AllowVideoAdjustments. You need to do the same in C# and have an interval timer object waiting for the State to hit Playing before re-sizing, etc. Sorry but there's no way I can force Vlc to load and start playing immediately, since it might just timeout and fail to load completely, so there's no way to examine the video properties before it starts Playing some unknown time in the future.

One enhancement I'm thinking about adding for my own piece of mind is to implement a callback when the State variable changes. I figured out how to do callbacks with the Now Playing event (which I use to show ShoutCast internet radio tracks, btw) so it shouldn't be that hard.

Posted: 18 Jan 2007 11:12
by osmanosman
a litle question
.net interface using this settings file
C:\Documents and Settings\user\Application Data\vlc\vlcrc

Is there any way to hinder using this file or change file name?

Call Back Functions...

Posted: 18 Jan 2007 16:27
by sgross
Tappen, That would be great if there was just a call back. I'll use the timer for now. I figured that is what was going on.

On another note,
Sometimes if I load multiple VLC windows and one is overlapped, the bottom window goes black. for example, If I have 5 windows open and the sixth loads on top of the 1st, the first would go black, but I can drag that 6th windows around and the other windows continue to play correctly.

Any ideas? Is there a better forum for this question?

Posted: 18 Jan 2007 22:16
by osmanosman
use "no-overlay" for black screen

Code: Select all

string[] initOptions = { "vlc", "--no-one-instance", "--no-overlay", "--no-snapshot-preview", "--no-drop-late-frames", "--disable-screensaver" };

I still can't get VLanControl working in VB.NET 2005

Posted: 19 Jan 2007 11:39
by nkarnold
Can anyone post some good example code (not pseudo). of using the Control.

I've already tried the authors suggestion of making the parent of the control, the form. No joy, just lots of exception messages.

Keep up the good work.


Fingers crossed for some VB.NET 2005 example.

Cheers

N

Posted: 20 Jan 2007 04:01
by Tappen
Sorry I don't do VB.NET, but in C# you'd create a new Windows Application project named Foo and save it. Then copy VLanControl.dll, VLanControl.pdb, libvlc.dll, and the plugins directory to the Foo\Foo\bin\Debug directory of the new project. Add a reference to VLanControl.dll in the new project by Browsing to the same bin\Debug directory.

In Form1.cs of the new project you could put

Code: Select all

public partial class Form1 : Form { VLanControl.VlcUserControl vlc = new VLanControl.VlcUserControl(); Timer timer; bool sizingNeeded; public Form1() { InitializeComponent(); vlc.Parent = this; vlc.Dock = DockStyle.Fill; } protected override void OnLoad(EventArgs e) { base.OnLoad(e); this.sizingNeeded = true; this.vlc.AddAndPlay(@"YourMediaFile.ext", ""); this.timer = new Timer(this.components); this.timer.Interval = 500; this.timer.Tick += timer_Tick; this.timer.Start(); } void timer_Tick(object sender, EventArgs e) { if(this.sizingNeeded && (this.vlc.State == VLanControl.PlayerState.Playing)) { this.ClientSize = this.vlc.VideoSize; this.sizingNeeded = false; } } }
Change the name of the media file and you have yourself a simple player application. This doesn't Dispose of things properly but it's the smallest useful project I can think of.

How can I access the messages from C# ?

Posted: 20 Jan 2007 15:27
by eiden
Tappen, thanks for the excellent work!

I have a question.

How can I access the information that is displayed in the messages window (View -> Messages) from C#?

Posted: 20 Jan 2007 19:35
by Tappen
The short answer is to wait for me to write the code, or look at the ActiveX source code and move that to C# yourself. I haven't looked into Messages.

Posted: 20 Jan 2007 19:39
by eiden
The short answer is to wait for me to write the code, or look at the ActiveX source code and move that to C# yourself. I haven't looked into Messages.
Ok. Thanks for the answer :) Now I know where to look.

VB.NET Example

Posted: 21 Jan 2007 01:17
by nkarnold
Thanks for that, I've managed to get it going in VB.NET now.. I didn't realise that the plugins directory had to be under directory where the compiled binary was run from (I saw the --plugins path in your code)

Any way. For those VB.NET'rs.. below is the example
Add vlancontrol to your vb.net project as a reference

Code: Select all

Private Sub PlayVideoFile() Dim Video As New VLanControl.VlcUserControl Dim sFilename As String, sTitle As String Dim Options(2) As String Video.Parent = Me Video.Dock = DockStyle.Fill sFilename = "dvdsimple://E:@1:2" ' Replace this with your video file, stream, dvd path etc.. sTitle = "My Video File" Options(0) = ":volume=75" ' These can be any of the VLC options, replace as needed Options(1) = ":audio-track=0" Video.ClearPlayList() Video.AddToPlayList(sFilename, sTitle, Options) Video.Play() ' At this point, you may want to start a timer or a thread and monitor ' video.isplaying ' video.time End Sub

Posted: 08 Feb 2007 17:01
by retevenard
Hi,

Maybe it's a stupid question but where I can find the file VLanControl.dll.

I didn't see a link to download this file on the http://wiki.videolan.org/.Net_Interface_to_VLC

Thanks for your answer.

Posted: 08 Feb 2007 17:09
by sgross
Hi,

Maybe it's a stupid question but where I can find the file VLanControl.dll.

I didn't see a link to download this file on the http://wiki.videolan.org/.Net_Interface_to_VLC

Thanks for your answer.
You have to copy all the code into Visual Studio and then compile the project. This generates the VLanControl.dll that you can then add to the toolbox.

Posted: 09 Feb 2007 09:05
by retevenard
Thanks for your answer but someone can send me this dll to my email renaud_sadus@hotmail.com.

Thanks in advance.

Posted: 15 Feb 2007 14:12
by GJ
Hi,

First of all, thanks for the VLanControl.dll.
As I'm quite new at programming it really helps me a lot.
Tappen,

have you seen that :

http://wiki.videolan.org/MediaControlAPI#Full_API

How can you get informations about current playlist ?
As zbe I'm wondering, how I can get the playlist.

I could not figure out.
I'm using the VlcControl.
Added some files.
Video is playing, and I tried to get the playlist with "vlc.Programs()", but it keeps returning an empty array.

Can anybody please give me a hint, how I can get the playlist?

Thanks

Posted: 16 Feb 2007 13:34
by Cooldream
Hello,
I don't know the C#.
I use VB6 and I could try VB.net 2005.
Could someone give me a complete exemple in VB6 or VB.net (the code and the VLanControl.dll compiled) ?

Thanks...

Posted: 19 Feb 2007 16:14
by sgross
Hello,
I don't know the C#.
I use VB6 and I could try VB.net 2005.
Could someone give me a complete exemple in VB6 or VB.net (the code and the VLanControl.dll compiled) ?

Thanks...
Sorry, I don't know normally work in VB and unfortunately do not have the time to convert it for you.

Disposing of things properly...

Posted: 11 Apr 2007 04:59
by sgross
Sorry I don't do VB.NET, but in C# you'd create a new Windows Application project named Foo and save it. Then copy VLanControl.dll, VLanControl.pdb, libvlc.dll, and the plugins directory to the Foo\Foo\bin\Debug directory of the new project. Add a reference to VLanControl.dll in the new project by Browsing to the same bin\Debug directory.

In Form1.cs of the new project you could put

Code: Select all

public partial class Form1 : Form { VLanControl.VlcUserControl vlc = new VLanControl.VlcUserControl(); Timer timer; bool sizingNeeded; public Form1() { InitializeComponent(); vlc.Parent = this; vlc.Dock = DockStyle.Fill; } protected override void OnLoad(EventArgs e) { base.OnLoad(e); this.sizingNeeded = true; this.vlc.AddAndPlay(@"YourMediaFile.ext", ""); this.timer = new Timer(this.components); this.timer.Interval = 500; this.timer.Tick += timer_Tick; this.timer.Start(); } void timer_Tick(object sender, EventArgs e) { if(this.sizingNeeded && (this.vlc.State == VLanControl.PlayerState.Playing)) { this.ClientSize = this.vlc.VideoSize; this.sizingNeeded = false; } } }
Change the name of the media file and you have yourself a simple player application. This doesn't Dispose of things properly but it's the smallest useful project I can think of.
Could someone post exactly how to "Dispose of things properly"? I want to make sure I'm doing things correctly.

Thank you in advance

C# downloader...

Posted: 12 Apr 2007 19:35
by dl0haus
I'm curious how I might go about accessing VLC's live stream downloading capability through the DLL? I'm writing a C# application that needs this ability... I wrote a custom implementation of MMS (a pain) and thought I'd try out the DLL.

Basically I have live streams at a designated address that can be MMS/RTSP/HTTP and I want to save them to a local file. The VLC player has this functionality but I was wanting to accomplish the same thing without playing the files locally, just doing a raw download to ASF.

Any ideas or samples?
Thanks,
D

Re: C# downloader...

Posted: 12 Apr 2007 19:50
by sgross
I'm curious how I might go about accessing VLC's live stream downloading capability through the DLL? I'm writing a C# application that needs this ability... I wrote a custom implementation of MMS (a pain) and thought I'd try out the DLL.

Basically I have live streams at a designated address that can be MMS/RTSP/HTTP and I want to save them to a local file. The VLC player has this functionality but I was wanting to accomplish the same thing without playing the files locally, just doing a raw download to ASF.

Any ideas or samples?
Thanks,
D
If you follow the example I quoted in my last post, you just need the correct string the following line...

Code: Select all

this.vlc.AddAndPlay(@"YourMediaFile.ext", "");
The simple way to create the correct string is to load VLC and play the stream the way you want and use the string genereated in the Open Dialog box.

The string is in Advanced Options. That opens the correct stream. Then click on the Settings button and select your streaming options. This generates the "Stream Output MRL" When those two strings are correctly added to the AddandPlay command it should work.

Let me know how it turns out, I'm planning on doing something similar in a few weeks.