VideoLan.Interop a .Net libvlc 0.9.x wrapper

This forum is about all development around libVLC.
pinturic
New Cone
New Cone
Posts: 1
Joined: 31 Jul 2007 17:27

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

Postby pinturic » 19 Dec 2008 13:39

Compliment for your great work!

I am currently trying to loop (or at least repet a certain amount of time) a media_list but i was not able to do it. Have you ever succeded in doing it ?

e.beckers
New Cone
New Cone
Posts: 5
Joined: 23 Dec 2008 15:10

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

Postby e.beckers » 23 Dec 2008 15:52

I noticed a memory leak with the wrapper
More details are posted here viewtopic.php?f=32&t=47385&start=90#p177639

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 » 24 Dec 2008 06:25

I noticed a memory leak with the wrapper
More details are posted here viewtopic.php?f=32&t=47385&start=90#p177639
Which wrapper are you referring to? Those two forum thread refers to two different wrapper? Plus, what version of videolan are you using?

e.beckers
New Cone
New Cone
Posts: 5
Joined: 23 Dec 2008 15:10

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

Postby e.beckers » 24 Dec 2008 08:13

Which wrapper are you referring to? Those two forum thread refers to two different wrapper? Plus, what version of videolan are you using?
I noticed the memory leak in both wrappers
And i've tried VLC 0.98a and VLC 0.96

Erwin

mnn
New Cone
New Cone
Posts: 6
Joined: 12 Oct 2008 15:22

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

Postby mnn » 24 Dec 2008 11:14

I guess the problem isn't in wrapper but in libVlc itself...

e.beckers
New Cone
New Cone
Posts: 5
Joined: 23 Dec 2008 15:10

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

Postby e.beckers » 24 Dec 2008 13:25

I guess the problem isn't in wrapper but in libVlc itself...
Is VLC.exe itself using libVLC ?
Since i dont see the memory leak when looping the same video in vlc.exe

Erwin

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 » 24 Dec 2008 22:43

Thanks for the sample, I've been able to reproduce this. I'll have to play around some more to see if the problem is the wrapper or libvlc. As far as I know, libvlc exposes external functions that I use. Those functions handle the locking/threading and call the internal functions VLC.exe uses. So the problem could be in libvlc but not appear in VLC.

bondehagen
New Cone
New Cone
Posts: 1
Joined: 28 Dec 2008 17:03

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

Postby bondehagen » 28 Dec 2008 17:12

Thank you for sharing this interop, well done. I'm trying to get WPF support working, have you done any progress or anyone else?

mikea32
New Cone
New Cone
Posts: 3
Joined: 29 Dec 2008 00:16

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

Postby mikea32 » 29 Dec 2008 00:19

currently using this wrapper to get vlc playing a video in a WPF program (using the windows form host control). Is it possible to get mouse click events from the area that the video is playing? (and stop the double click->full screen event?)

ChrisHolmesOnline
Blank Cone
Blank Cone
Posts: 19
Joined: 13 Dec 2008 00:55

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

Postby ChrisHolmesOnline » 31 Dec 2008 17:36

This wrapper is not working for me. I grabbed publicEnemy's code from here: http://www.syairin.com/SimplePlayer.7z

All I get is a blank screen. Details:

WindowsXP
VLC 0.9.8

I've got all the VLC files copied where they're supposed to be, still no joy. I've added the path to the VLC directory as an argument to the VideoLanClient constructor, still no luck.

I'd die for an actual working example of a C# WinForms program with an embedded VLC client. If anyone has a working, full, complete example (with your .mov file included) please e-mail me. I'm getting weary trying to get any of the C# wrappers to work. Nothing is working for me.

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 » 01 Jan 2009 08:21

You can trap mouse and keyboard events by using the Win32 low level hooks. I've used them successfully to pop up a panel of buttons when playing a movie full screen.

Steve

mikea32
New Cone
New Cone
Posts: 3
Joined: 29 Dec 2008 00:16

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

Postby mikea32 » 01 Jan 2009 20:20

that won't let me swallow the double click->fullscreen that vlc does. From browsing this forum it appears the only way is to edit the source for the vout module and compile it myself

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 » 01 Jan 2009 21:34

I'm almost sure it will. Here's my code.

Code: Select all

/* Data structures */ private static int WH_MOUSE_LL = 14; private static int wm_LButtonDown = 513; private static int wm_LButtonUp = 514; private static int wm_RButtonDown = 516; private static int wm_RButtonUp = 517; [System.Runtime.InteropServices.DllImport("kernel32.dll")] private static extern IntPtr GetModuleHandle(string moduleName); [System.Runtime.InteropServices.DllImport("user32.dll")] private static extern IntPtr SetWindowsHookEx(int idHook, HookProc lpfn, IntPtr hMod, uint dwThreadId); [System.Runtime.InteropServices.DllImport("user32.dll")] private static extern bool UnhookWindowsHookEx(IntPtr idHook); [System.Runtime.InteropServices.DllImport("user32.dll")] private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, uint wParam, IntPtr lParam); [StructLayout(LayoutKind.Sequential)] public class POINT { public int x; public int y; } [StructLayout(LayoutKind.Sequential)] public class MouseLLHookStruct { public POINT pt; public int mouseData; public int flags; public int time; public int dwExtraInfo; } private static HookProc hookProc; private static IntPtr hook; private static GCHandle hookProcHandle; private static GCHandle hookHandle; private delegate IntPtr HookProc(int nCode, uint wParam, IntPtr lParam); /* This code is used during window intialization. */ hookProc = new HookProc(LowLevelMouseProc); hook = SetWindowsHookEx(WH_MOUSE_LL, hookProc, GetModuleHandle(null), 0); hookProcHandle = GCHandle.Alloc(hookProc, GCHandleType.Normal); hookHandle = GCHandle.Alloc(hook, GCHandleType.Normal); /* Heres the hook code */ private static IntPtr LowLevelMouseProc(int nCode, uint wParam, IntPtr lParam) { if (wParam != wm_LButtonDown && wParam != wm_LButtonUp && wParam != wm_RButtonDown && wParam != wm_RButtonUp) { return CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam); } if (wParam == wm_LButtonDown || wParam == wm_RButtonDown) return (new IntPtr(1)); MouseLLHookStruct hookStruct = (MouseLLHookStruct)Marshal.PtrToStructure(lParam, typeof(MouseLLHookStruct)); if (hookStruct.pt.x > SystemParameters.WorkArea.Width || hookStruct.pt.y > SystemParameters.WorkArea.Height) { showControls(); // This routine shows my control buttons. return (new IntPtr(1)); } return CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam); }
You also need to call the unhook API (UnhookWindowsHookEx(hook);) some place in your code.

As I said before I use Libvlc to play movies (and other media) fullscreen. The user moves the mouse pointer off the screen and clicks either button to get my control buttons to show.

With this code double clicking or right clicking with the mouse over the movie that is playing does nothing.

After trying various early Libvlc frameworks I developed my own which covers most of the public API apart from VLM and is more .Net orientated (ie indexed collections, events, exceptions). I also have a simple Winforms test harness for it and you are welcome to have the code for both if it's of any use. It's built with VS2008 and I currently use it with VLC 0.9.8a. My 'production' system is a WPF application with my framework using WinformsHost and that seems to work fine.

Regards

Steve

mikea32
New Cone
New Cone
Posts: 3
Joined: 29 Dec 2008 00:16

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

Postby mikea32 » 02 Jan 2009 15:26

with some changes to suit my needs (eg my app won't be fullscreen so need to know if the mouse is over my window or not) the code works fine, thanks :)

edit: only problem is the mouse hook doesn't give indication of an actual mouse click, i can do single clicks fine by remembering mouse down status etc but i have no idea on how to do a double click without firing a single click event first

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 » 02 Jan 2009 21:26

I'm not clear what your issue is but if it's any help there is a Win32 mouse input function GetDoubleClickTime. You could probably use that to somehow detect a double click.

Steve

belanur
New Cone
New Cone
Posts: 1
Joined: 04 Jan 2009 15:03

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

Postby belanur » 04 Jan 2009 15:09

Hi all,

I've been using VideoLan.Interop in my C# Project for audio and video playback which works really great so far. There is one problem I don't understand though. I try reading meta data from the currently loaded media by calling vlcMedia.ReadMeta(), which gives me a System.AccessViolationException.

Here is my code:

Code: Select all

public class vlcWrapper { private VideoLan.VideoLanClient vlc; private VideoLan.VlcMediaPlayer vlcPlayer; private VideoLan.VlcMedia vlcMedia; public vlcWrapper(IntPtr _videoHandle) { this.vlc = new VideoLan.VideoLanClient(); this.vlcPlayer = vlc.NewMediaPlayer(_videoHandle); } public void LoadFile(string aFilename) { this.vlcMedia = this.vlc.NewMedia(aFilename); this.vlcMedia.AddOption(@":no-video-title-show"); this.vlcPlayer.Load(this.vlcMedia); } public void Play() { if (this.vlcMedia != null) { this.vlcPlayer.Audio.ToggleMute(); this.vlcPlayer.Play(); } } public void Pause() { this.vlcPlayer.Pause(); } public void Stop() { this.vlcPlayer.Stop(); } public string GetMediaTitle() { string title = ""; if (this.vlcMedia != null) { title = this.vlcMedia.ReadMeta(VideoLan.libvlc_meta_t.libvlc_meta_Title); } return title; } }
Any hints?

Thanks!

justcallmefrank
New Cone
New Cone
Posts: 3
Joined: 15 Dec 2008 04:49

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

Postby justcallmefrank » 07 Jan 2009 00:41

Hey dude,

Been playing with it a bit more, I'm only interested in audio at the moment, and it's going great.

Just a quick question, is it possible to raise the priority of the VLC thread so it has priority over everything else in the application? I get quite a big hit when I load some of the album covers in my interface which causes the music to pause momentarily. I'd like to eliminate this and giving the video priority seems to be the best way to achieve this, I just don't know enough about the interop stuff yet.

Cheers,
Nathan

drewdb
New Cone
New Cone
Posts: 8
Joined: 09 Jan 2009 08:53

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

Postby drewdb » 09 Jan 2009 09:10

Hi to all. I am new to vlc and have tried all of the wrappers and this one looks easier to use which i guess was the idea.

I need to make a program to utilize the streaming of vlc (udp multicast) and was hoping that this interop is capable of this. I can play a video but i can't see where you can create the multicast stream.

I this possible with this dll?

akramh
New Cone
New Cone
Posts: 5
Joined: 27 Jun 2008 04:40

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

Postby akramh » 10 Jan 2009 01:47

Hey dude,

Been playing with it a bit more, I'm only interested in audio at the moment, and it's going great.

Just a quick question, is it possible to raise the priority of the VLC thread so it has priority over everything else in the application? I get quite a big hit when I load some of the album covers in my interface which causes the music to pause momentarily. I'd like to eliminate this and giving the video priority seems to be the best way to achieve this, I just don't know enough about the interop stuff yet.

Cheers,
Nathan
You can manually set the priority of a thread in .NET, but all bets are off as to whether the OS decides to honour your 'request' to change priority. Note that this requires you to be able to get a reference to the VLC thread.

Read more here: http://msdn.microsoft.com/en-us/library ... ority.aspx

hth,

Akram

Valk
New Cone
New Cone
Posts: 5
Joined: 25 Nov 2008 06:41

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

Postby Valk » 20 Jan 2009 09:08

You can use this wrapper to run libVlc in the background. As long as you can figure out the options to use there is no reason this library can't be used as a streaming server.

The only small change you have to do is edit the Initalize function in VideoLanClient.cs

Comment out:

Code: Select all

//cbSurfaceChanged = new D3dCallback(SurfacedChanged); //InteropMethods.libd3d_surface_changed_callback(cbSurfaceChanged);
I'm pritty sure that was all the changes I did (its been a while since I had to modify it). There might be more but the debugger will help you track those down.

Once those lines are commented just point vlc to IntPtr.Zero instead of a handle for it to render to and your set.
If you do set it to duplicate the stream to some form of local play it will bring up a form which it will output in.

* Note: I haven't read the whole thread, just the last few posts and saw someone ask about multi-cast streaming so I thought i'd add this bit. Sorry if someone else mentioned something similar or there has been a update to allow this already.

elund
Blank Cone
Blank Cone
Posts: 18
Joined: 22 Jan 2009 10:42

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

Postby elund » 22 Jan 2009 14:18

This wrapper is not working for me. I grabbed publicEnemy's code from here: http://www.syairin.com/SimplePlayer.7z
All I get is a blank screen. Details:
WindowsXP
VLC 0.9.8
Hmm! I have the same problem. Did you find a solution?

I was also able to compile all samples from http://meedios.svn.sourceforge.net/view ... n%200.9.0/.
But the result is the same. I am not able to play any movies with the samples. Just an empty screen, no error messages. What's the clue on this?

Best regards, Elund

elund
Blank Cone
Blank Cone
Posts: 18
Joined: 22 Jan 2009 10:42

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

Postby elund » 22 Jan 2009 14:55

Hmm! I have the same problem. Did you find a solution?
Argh!Stupid me ;-) I was missing the plugins sub-directory below the sample programs.

Best regards, Elund

elund
Blank Cone
Blank Cone
Posts: 18
Joined: 22 Jan 2009 10:42

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

Postby elund » 26 Jan 2009 09:55

To test the functionality of clearing the playlist I have added a button to the VlcMediaListPlayer.Sample application:

private void button1_Click(object sender, EventArgs e)
{
int nCount = VlcPlayer.PlayList.Count;
for (int i = 0; i < nCount; i++)
VlcPlayer.PlayList.RemoveAt(i);
}

This results in an unhandled exception of type 'System.AccessViolationException' occurred in VideoLan.Interop.dll.

Additional information is something about a try to read or write in a protected memory.

Any ideas to fix this problem?

Best regards, Elund

rvbcrs
New Cone
New Cone
Posts: 1
Joined: 26 Jan 2009 13:17

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

Postby rvbcrs » 26 Jan 2009 13:24

Hi Kairos,

First of all I have to say great wrapper I really like it. I have a small question I hope you or anyone in here could answer.. I'm building a little application that can display a RTSP stream, I'm behind my company's firewall so the RTSP port 554 is blocked, I could change the RTSP port of the streaming source but I rather want to try a HTTP Tunnel. this is where the problem starts, I have no idea how to use a proxy server with the VLC wrapper, I have tried the following:

Code: Select all

vlcMediaStream.AddOption("--rtsp-tcp"); vlcMediaStream.AddOption("--socks=\"localhost:1080\""); //vlcMediaStream.AddOption(":socks=\"localhost:1080\""); vlcMediaPlayerStream.Load(vlcMediaStream); vlcMediaStream.Dispose(); vlcMediaPlayerStream.Play();
As you can see I also tried the .AddOption that is commented out, but this wasn't working too. Can anybody help me out here?

Thanks,

RvBCrS

astlin
New Cone
New Cone
Posts: 3
Joined: 27 Jan 2009 12:25

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

Postby astlin » 27 Jan 2009 13:24

cool. thnx for a great job! i need to play multiple video streams from different source urls on one form (preferably in PictureBoxes). can't get how to do it, any working sample?


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 18 guests