VideoLan.Interop a .Net libvlc 0.9.x wrapper

This forum is about all development around libVLC.
DennisL
New Cone
New Cone
Posts: 4
Joined: 30 Oct 2008 18:41

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby DennisL » 01 Nov 2008 12:18

I'm really not sure what the problem is because I can't reproduce it at all. Do you have VLC installed or are you just using the zipped up binaries? Are you just pointing your app at the vlc install or are you copying all the vlc binaries over to your application?
I have the latest VLC release installed and read the installation dir from the registry. I then pass this path as argument to the constructor.

DennisL
New Cone
New Cone
Posts: 4
Joined: 30 Oct 2008 18:41

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby DennisL » 02 Nov 2008 18:08

I'm really not sure what the problem is because I can't reproduce it at all. Do you have VLC installed or are you just using the zipped up binaries? Are you just pointing your app at the vlc install or are you copying all the vlc binaries over to your application?
I did investigate on the issue a little further. When I copy the dlls over to my app, it works just fine. The issue does not come up and videos are played each and every time I start the app. On the other hand, when I point the app to a vlc install the error comes up. Maybe this might help you to track down the bug.

-Dennis

publicENEMY
Cone that earned his stripes
Cone that earned his stripes
Posts: 104
Joined: 14 May 2007 05:04
Location: Malaysia

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby publicENEMY » 03 Nov 2008 11:00

Hi.

Ive created a simple player(and i mean really simple) to learn/test VideoLan.Interop from Kairos. Here are the source and executable.
http://www.syairin.com/SimplePlayer.7z

ImageImage

Steps
1. Extract to a folder
2. copy all dll from the main directory of latest videolan installation (tested with 0.9.4) to SimplePlayer\bin\Debug
3. copy plugins folder from the main directory of latest videolan installation (tested with 0.9.4) to SimplePlayer\bin\Debug
4. compile and run

Notes
1. the reason im using panel for video handle is because Kairos is using it for its video handle
2. the purpose of this is for learning. although i tried it to be as resource friendly as possible
3. if you have suggesion, feel free to comments
4. playlist is not implemented. maybe next time. maybe using videolan playlist, or .net playlist. i donno which one is better. although i believe, a .net playlist would be better
5. if you think i have bad naming habits, feel free to suggest

Features
1. Media position slider
2. Able to open media from files, streaming, etc. Can handle MRL options. see list of options here http://wiki.videolan.org/VLC_command-line_help
3. Volume slider
4. Play, Pause, Stop

Next
1. playlist
2. display metadata
3. (any suggestion)

Thanks.

publicENEMY
Cone that earned his stripes
Cone that earned his stripes
Posts: 104
Joined: 14 May 2007 05:04
Location: Malaysia

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby publicENEMY » 04 Nov 2008 07:38

Line 136 in file Form1.cs

Code: Select all

if ( position < mediaTrackBar.Maximum || position > mediaTrackBar.Minimum)
should be

Code: Select all

if ( position < mediaTrackBar.Maximum && position > mediaTrackBar.Minimum)

publicENEMY
Cone that earned his stripes
Cone that earned his stripes
Posts: 104
Joined: 14 May 2007 05:04
Location: Malaysia

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby publicENEMY » 04 Nov 2008 10:58

Kairos.

How can i get media MRL, its options and media metadata during playback?

thanks.

m.e
Blank Cone
Blank Cone
Posts: 34
Joined: 27 Jan 2006 23:42

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby m.e » 04 Nov 2008 11:45

How can one get available subtitle tracks using this api?

SteveBickell
Blank Cone
Blank Cone
Posts: 13
Joined: 10 Sep 2008 01:18

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby SteveBickell » 10 Nov 2008 21:31

Hi Kairos,

Like you I have developed a .Net Libvlc wrapper for use in a larger project. It was originally inspired by the Marx wrapper but I ended up rewriting it and it now wraps almost all of the functions exported by Libvlc excluding VLM. Looking at your code they are remarkably similar (no handles visible, enumerable lists, simplified exception handling etc).One additional class I have developed deals with the myriad of options VLC has and tries to add proper validation and context checking but it's a long haul.

What your code enabled me to do was sort out events which I had never managed to get to work. The attribute declaration on the callback fixed my problem but that led on to another. Using your offsets in VlcCallbackArgs the callback data was always wrong apart from the first field (event type) until I changed offset 8 to offset 4 and offset 16 to offset 8 and then everyting was OK. Even the media handles passed in some callbacks pointed to media items I could access successfully.

Are you sure your offsets are correct?

Incidentally I agree with you that polling the status is (in most cases) a better option than using events.

If you manage to get a fully integrated WPF implementation to work you would be very popular in the WPF community. Apparently the MediaElement control is pretty limited (and unpopular).

Regards

Steve

Kairos
Blank Cone
Blank Cone
Posts: 45
Joined: 01 Mar 2008 01:49
Operating System: Windows
Location: Scottsdale, Az
Contact:

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby Kairos » 12 Nov 2008 08:17

On the contrary, I know my offsets are wrong. When I originally wrote it, I did the math and came out with the same offsets you stated. Problem was when I looked at the data it was all garbage. For some reason the computer I develop on stores each field as 8 bits :shock: . I have no idea why this happens, but in order to actually code and test the events I had to set the bit sizes to 8 bits. I usually switch them back when I compile for release mode. But thanks for pointing that out, I'll make that part of conditional compile code block.

Steve, your right. It is funny how similar they sound. I was planing on making a VlcConfiguration class to encapsulate the command line parameters. Ultimately I decided there was too much work for too little reward. Anyway, I'm glad my code was useful in getting your events working.

BexX
Blank Cone
Blank Cone
Posts: 18
Joined: 16 Jul 2008 00:26

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby BexX » 22 Nov 2008 13:47

this should be a sticky imho, because this wrapper is actually under development and more complete compared to marx wrapper.

BexX
Blank Cone
Blank Cone
Posts: 18
Joined: 16 Jul 2008 00:26

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby BexX » 22 Nov 2008 14:16

Hi Kairos,

i did some work on getting this wrapper to work on ubuntu/mono 1.91... and using this constructor it does work!

Code: Select all

// mono/linux Constuructor public VideoLanClient(string[] args) { //Initalize our exception pointer p_exception = new libvlc_exception_t(); p_exception.Initalize(); //create out vlc instance this.p_instance = InteropMethods.libvlc_new(args.Length, args, ref p_exception); p_exception.CheckException(); }
I am going to think about this whole constructor code in the VideoLanClient class and hopefully this thinking results in clean way working cross plattform! :)

surf_uk
New Cone
New Cone
Posts: 5
Joined: 23 Oct 2008 18:13

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby surf_uk » 24 Nov 2008 12:16

I'm glad I referenced your code in the marx' awesome thread, it seams it is THE vlc wrapper - awesomer!

however I'm just getting back into developing my vlc player and only just getting chance to try your mighty wrapper. I have stumbled into a problem already, I don't have the "plugins\libd3dimage_plugin.dll" despite having the latest VLC 0.9.6...

As a result the VideoLanClient class falls over as it cannot find:
InteropMethods.libd3d_surface_changed_callback(cbSurfaceChanged);

I have downloaded your tarball from MeediOS:
http://meedios.svn.sourceforge.net/view ... z?view=tar

I notice this project failed to load during when opening the solution:

Code: Select all

/* The following error has occurred during XML parsing: File: C:\Projects\Auxiliary\VideoLan 0.9.0\D3DImage_Bridge\D3DImage_Bridge.vcproj Line: 10 Column: 2 Error Message: '9.00' violates enumeration constraint of '7.00 7,00 7.10 7,10 8.00 8,00'. The attribute 'Version' with value '9.00' failed to parse. The file 'C:\Projects\Auxiliary\VideoLan 0.9.0\D3DImage_Bridge\D3DImage_Bridge.vcproj' has failed to load. */
So close! can anyone post the dll maybe? - it seams I'm not alone either
Last edited by surf_uk on 25 Nov 2008 10:06, edited 1 time in total.

Freundschaft
New Cone
New Cone
Posts: 1
Joined: 24 Nov 2008 21:31

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby Freundschaft » 24 Nov 2008 22:35

ehrm, where do i get the libd3dimage_plugin.dll from?

publicENEMY
Cone that earned his stripes
Cone that earned his stripes
Posts: 104
Joined: 14 May 2007 05:04
Location: Malaysia

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby publicENEMY » 25 Nov 2008 05:17

*deleted*
Last edited by publicENEMY on 26 Nov 2008 06:14, edited 1 time in total.

surf_uk
New Cone
New Cone
Posts: 5
Joined: 23 Oct 2008 18:13

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby surf_uk » 25 Nov 2008 10:18

Don't take it personally I'm not the type of guy to flame anything - have changed my quote to:
I'm glad I referenced your code in the marx' awesome thread, it seams it is THE vlc wrapper - awesomer!
Sorry to marx if I did offend, his wrapper has helped me a lot as I posted on his thread. Just found it funny that by posting a link to Kairos vlc interop we now have active engagement with an up to date wrapper, thanks very much Kairos for keeping an eye out and for your contribution!
he DID actually contribute to the community.
In a way I have contributed already by pointing out there's a good alternative :) I'm trying to get to the point where I can start contributing... wanna help me?

Kairos
Blank Cone
Blank Cone
Posts: 45
Joined: 01 Mar 2008 01:49
Operating System: Windows
Location: Scottsdale, Az
Contact:

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby Kairos » 25 Nov 2008 17:30

Sorry about that guys. I broke the build :oops:

As was stated earlier in this thread I'm also working on getting VLC into WPF. That is what the D3DImage_Bridge dll is and also the "#if USE_WPF" are doing in the code. I've temporarily removed the project from the 2005 sln file. Currently its more of a proof of concept project. Anyway, it is not needed if you just want to use the wrapper. The wrapper is the VideoLan.Interop.dll. Everything else are just samples or test code.

Kairos
Blank Cone
Blank Cone
Posts: 45
Joined: 01 Mar 2008 01:49
Operating System: Windows
Location: Scottsdale, Az
Contact:

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby Kairos » 25 Nov 2008 17:46

@BexX, can you download the new code and try it. I have a feeling the problem was with the way I was finding the plugins directory. I've modified it so it uses Path.Combine which mono should translate into the linux directory structure.

BexX
Blank Cone
Blank Cone
Posts: 18
Joined: 16 Jul 2008 00:26

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby BexX » 26 Nov 2008 00:48

The Problem was caused by these two lines, you have put into an if directive now.

Code: Select all

135 #if USE_WPF 136 cbSurfaceChanged = new D3dCallback(SurfacedChanged); 137 InteropMethods.libd3d_surface_changed_callback(cbSurfaceChanged); 138 #endif
There should not be a problem finding the plugins directory on linux, as these should be located in /usr/lib or /lib, i.e. in the search path, in a proper install. However there is a problem on using the wrapper (similar for jvlc) I encoutered on Ubuntu Interpid: mono will fail to load libvlc.so as it is named "libvlc.so.2" in "/usr/lib/". This can be solved by simply creating an symlink:

Code: Select all

sudo ln -s /usr/lib/libvlc.so.2 /usr/lib/libvlc.so
PS: There is something i forgot to say: Great work kairos! No need to be embaressed! :D Thumbs up!

sun_yiqin
New Cone
New Cone
Posts: 4
Joined: 11 Nov 2008 03:08

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby sun_yiqin » 28 Nov 2008 07:59

Hi,ALL!
My program throw an exception"The data area passed to a system call is too small"
on running "VideoLanClient videoLanClient = new VideoLanClient();".

Does anybody has the same problem?
Help me! Thanks!

dlfl
New Cone
New Cone
Posts: 9
Joined: 03 Dec 2008 02:47

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby dlfl » 03 Dec 2008 03:39

Plus one on the kudos, Kairos! This looks real nifty!

I ran into a problem with the MediaPlayer.Sample program:
(This is on Windows XP, using the Auxiliary Tarball downloaded tonight and the 0.9.7 VLC binaries.)
First I bulit the solution, absolutely no problem. Then I ran the MediaPlayer.Sample program and got the immediate "could not find dll error" which I expected.
Copied the libvlcore, libvlc dlls and the plugins folder into the bin\debug folder of my solution.
Then the sample program ran fine and I ran it several times.
I returned several minutes later and when I tried to run the program again I got a Visual C++ Runtime Library assertion failed error at line 844 in misc/objects.c.
From that point on the same error always occured when launching the program.

I finally discovered the following:
1. If you append a final backslash to the plugins path constructed in the VideoLanClient constuctor the error doesn't occur.
2. If you use the alternate VideoLanClient constructor and pass the path to the original binary install folder (where I installed the VLC player) the error doesn't occur and it doesn't matter whether you append the final backslash or not (??).

The really strange thing to me is why it worked the first few times before this error started happening? Must be some strange behavior of the Windows OS path handling code ??

Presumably the cross-platform solution to this is to append the Path.DirectorySeparatorChar field.

innerspace
Blank Cone
Blank Cone
Posts: 28
Joined: 10 Aug 2008 22:47
VLC version: 0.8.6
Operating System: Windows / OsX
Location: Thailand & England

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby innerspace » 05 Dec 2008 11:41

I downloaded the 0.9.x interop wrapper today (sourceforge revision 3328) and from first look it seems ideal to fix some problems I have been having in my 0.8.6 application.

However, it wont run!

I have tried both the vlcMediaSample and my own quick player attempt and both get stuck on line 41 (Initialize) of InteropMethods.cs with
{"Unable to load DLL 'libvlc': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"}
Debugging shows its hit at the line Vlc = new VideoLanClient();

I have already removed 0.8.6 (delete pref & cache), installed 0.9.4 and copied EVERY file from VLC root directory plus the plugins to my application debug folder. I remember having this problem before when I tried to test this wrapper.
Even publicENEMY's simple player throws the same error.

Also has anyone done some testing with this wrapper using the nightly 1.0.0 release?
With 0.9.8 (almost-for windows) out I would hope that an upgrade now will be compatible with the first full numbered release of VLC.
There were no visible differences between 0.9.4 and 1.0.0 although I didnt check in detail.

innerspace
Blank Cone
Blank Cone
Posts: 28
Joined: 10 Aug 2008 22:47
VLC version: 0.8.6
Operating System: Windows / OsX
Location: Thailand & England

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby innerspace » 05 Dec 2008 12:43

I got it working by pointing the wrapper to the vlc folder
vlc = new VideoLanClient("C:\\Program Files\\VideoLAN\\VLC");

but this brought me into DennisL's problem of not displaying video on a second opening.
starting a video in VLC reset this.

I solved the problem (I think) by adding the lines below with all dll and plugins in my executables folder

Code: Select all

String appPath = Application.ExecutablePath; String exeName = appPath.Split('\\').Last(); String vlcFolder = appPath.Remove(appPath.Length - exeName.Length); vlc = new VideoLanClient(vlcFolder);
It seems that having empty brackets in the new VideoLanClient() doesnt locate the applications folder as I would expect.

So unless this is fixed in future releases I reccommend anyone using this wrapper to place all dlls and plugins in your apps folder AND tell VideoLanClient WHERE your apps folder is.

I look forward to experimenting more with this wrapper, it seems very good so far.
At last I have position and state change callbacks rather than relying on a very hacked duration check improvisation! Thank you!

dlfl
New Cone
New Cone
Posts: 9
Joined: 03 Dec 2008 02:47

Re: The "DennisL problem"

Postby dlfl » 06 Dec 2008 07:17

I got it working by pointing the wrapper to the vlc folder
vlc = new VideoLanClient("C:\\Program Files\\VideoLAN\\VLC");

but this brought me into DennisL's problem of not displaying video on a second opening.
starting a video in VLC reset this.
.................
I'm running it this way and don't have the "DennisL problem." This is on two different XP Pro SP3 computers with two different versions of VLC installed, 0.9.7 and 0.9.8.

I resist the idea of having to copy all those files to the runtime folder. Distributing the app to the second computer required just copying the .exe and the interop dll (plus already having VLC player installed).

innerspace
Blank Cone
Blank Cone
Posts: 28
Joined: 10 Aug 2008 22:47
VLC version: 0.8.6
Operating System: Windows / OsX
Location: Thailand & England

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby innerspace » 07 Dec 2008 04:35

Ive now upgraded to 0.9.8 and DennisL's issue seems to be sorted.

Looks like it was a 0.9.4 specific problem. (Im running vista, dont know if thats related at all)

Also now in my simple test player I seem able to initialize vlc without the path to libvlc folder - noticed that the line I was going to add was already there.
However in my main application I get the same error as dlfl

So im still needing to use the fix I mentioned before, although simplified since I remembered an extra command
Any of the 3 appPaths below should work, depending where you position libvlc and plugins

Code: Select all

//string appPath = "C:\\Program Files\\VideoLan\\VLC" //string appPath = AppDomain.CurrentDomain.BaseDirectory; string appPath = Path.GetDirectoryName(Application.ExecutablePath); vlc = new VideoLanClient(appPath);
Thanks Kairos for an excellent wrapper - a few small bugs but they seem easily avoidable, this is definately the best 0.9 wrapper Ive used.

dlfl
New Cone
New Cone
Posts: 9
Joined: 03 Dec 2008 02:47

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby dlfl » 09 Dec 2008 04:24

Is this going to support streaming eventually (or does it already support it and I'm just too dumb to see it)?

I know when you setup streaming in the VLC Player you have to configure a bunch of things such as internet protocol, encapsulation, encoders, etc. I see streams in the object browser for videolan.interop but don't see anywhere to set these items.

innerspace
Blank Cone
Blank Cone
Posts: 28
Joined: 10 Aug 2008 22:47
VLC version: 0.8.6
Operating System: Windows / OsX
Location: Thailand & England

Re: VideoLan.Interop a .Net libvlc 0.9.x wrapper

Postby innerspace » 10 Dec 2008 05:29

What is the best way for handling VLC exceptions in this wrapper?
Does the statechanged.error get called before an unhandled exception error is sent out?

Not the easiest debugging when I have to wait an hour or 2 for a VLC crash and have a single chance to examine it.

My software runs VLC 24/7 and several times each day VLC crashes and I have to restart playing.

At the moment this requires restarting my entire program but I would much prefer to catch and handle the exception and just start a new instance of VLCMediaPlayer (or would a new VideoLanClient be better?)


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 7 guests