However, did you know that if you take any of the several C# wrapper previosly done for libvlc and call DLLImport in "separate threads" you do NOT keep seperate instances of the library?
Thx for your post. It's works.pass the .Handle member of the control you want to play in to video_set_parent.
I'm doing the same thing as you,but this is my work...And now my biggest problem is,when using the API of VLC,it requires some structures(such as "libvlc_instance_t"),and in these structures there're other structures,in other structures there're other structures...All these structures are declared in header files of VLC or cygwin.If I copy all the declaration of the structures to the header files of my project,that costs a lot of time;if I include all the header files of VLC and cygwin which related to,that make compiling errors(such as "inttypes.h","_types.h",can't pass compiling..).How to solve this problem?I don't know why <C# Wrapper for libvlc 0.9.0> doesn't need to either include .h files or declare structures...I´m doing a c++ wrapper for libvlc and will basing on your wrapper. So the lastest would save some work !
I am trying to use the "video_take_snapshot" method. It thinly wraps "libvlc_video_take_snapshot". No exception is raised, and a file is created, but the file is always 0 bytes in size and (obviously) does not contain an image.
All the parameters seem correct based on the API docs. I have tried bot explicitly setting the size and allowing the native size to be used (0,0 for width,height) but still nothing.
I have tried pausing first, and a number of other variations but still no luck. BTW I tried this with 0.9.2, 0.9.3, and the current nightly 0.9.4 and still luck.
Anyone know what I might be doing wrong? Has anyone ever gotten this to work?
The two problems mentioned happen to be related.
Firstly, libvlc_media_player.video_set_parent(libvlc_core.Handle, hDT, ex) in my multithreaded version needs to be placed after the play() command, or else I get a deadlock and the interface freezes. I've also had to wrap it in a try/Catch block to handle the exception.
The exception appears to be coming from libvlc, but does not effect binding VLC's output to the window. So, I think there may be a some code that references a null pointer within libvlc, after it has attached the output to a window.
When I get a chance, I'll get the wrapper finished. I have only two portions to do now, libvlc_vlm and libvlc_event. I need to review how the events are managed and the best way to connect to them. In fact, for a basic media player, you can avoid using libvlc_event and lib_vlm. In terms of state info, there are a few commands that will give you some info, anything that I found to be lacking I just created flags for in the interface and kept track of the state that way.Also I see that getting of state is not yet implemented. Is there any other way to get state?
Here is a copy of the latest build, I haven't had a chance to work on this the last few weeks, but I'll get back to it soon:
Marx libvlc Wrapper for 0.9.0 version 0.0.2 (Alpha Release)
http://www.2shared.com/file/3586524/6c4 ... apper.html
I was having the same problem, but i solved it copying every single dll that comes with the 0.9.2 win32 release, to the "bin/Debug" and "bin/Release".
It seems that it is not enough with just the libvlc.dll, libvlccore.dll and the plugins.
Code: Select all
public void AddAndPlay(string fileName, string options)
{
if (working)
return;
this.locca(true);
try
{
IntPtr hDT = this.Handle;
bool forceGC = false;
if (libvlc_media_player != null)
{
libvlc_media_player.Handle.Dispose();
libvlc_media_player = null;
forceGC = true;
}
if (libvlc_media != null)
{
libvlc_media.Handle.Dispose();
libvlc_media = null;
forceGC = true;
}
if (libvlc_core != null)
{
libvlc_core.Handle.Dispose();
libvlc_core = null;
forceGC = true;
}
ArrayList opz = (ArrayList)StandardArgs.Clone();
if (!String.IsNullOrEmpty(options))
{
foreach (string s in options.Split('\n'))
{
opz.Add(s);
}
}
string[] aopz = (string[])opz.ToArray(typeof(string));
libvlc_core = new Marx_libvlc_core(aopz, ref ex);
this.HandleRespose("new Marx_libvlc_core");
libvlc_media = new Marx_libvlc_media(libvlc_core.Handle, fileName, ref ex);
this.HandleRespose("new Marx_libvlc_media");
libvlc_media_player = new Marx_libvlc_media_player(libvlc_media.Handle, ref ex);
this.HandleRespose("new Marx_libvlc_media_player");
if (libvlc_media != null)
{
//Dispose of media Handle and force garbage collection
libvlc_media.Handle.Dispose();
libvlc_media = null;
forceGC = true;
}
if (forceGC)
{
GC.Collect();
GC.WaitForPendingFinalizers();
}
#if DEPRECATED
libvlc_media_player.play(ref ex);
this.HandleRespose("libvlc_media_player.play");
libvlc_media_player.video_set_parent(libvlc_core.Handle, hDT, ref ex);
// questa torna sempre un errore, per ora
exClass.clear(ref ex);
#else
libvlc_media_player.set_drawable(hDT, ref ex);
libvlc_media_player.play(ref ex);
this.HandleRespose("libvlc_media_player.set_drawable");
#endif
}
catch (Exception excp)
{
this.HandleResposeNET("AddAndPlay", excp);
}
finally
{
this.locca(false);
}
}
Code: Select all
public void stop(ref libvlc_exception_struct ex)
{
Thread.BeginThreadAffinity();
Thread.BeginCriticalRegion();
libvlc_media_player_stop(libvlc_media_player_handle, ref ex);
Thread.EndCriticalRegion();
Thread.EndThreadAffinity();
}
Code: Select all
Private _StopDone As Threading.ManualResetEvent
Private ex_g As libvlc_exception_struct
Public Sub [stop](ByRef ex As libvlc_exception_struct)
Dim t As New Threading.Thread(AddressOf _StopThread)
_StopDone = New Threading.ManualResetEvent(False)
ex_g = ex
t.Start()
If Not _StopDone.WaitOne(3000, False) Then System.Diagnostics.Debug.WriteLine("Media_Player_Stop: TIMEOUT")
End Sub
Private Sub _StopThread()
Dim ex As libvlc_exception_struct = ex_g
libvlc_media_player_stop(libvlc_media_player_handle, ex)
_StopDone.Set()
End Sub
Code: Select all
Private _ReleaseDone As Threading.ManualResetEvent
Protected Overrides Function ReleaseHandle() As Boolean
If (Not IsInvalid) Then
_ReleaseDone = New Threading.ManualResetEvent(False)
Dim t As New Threading.Thread(AddressOf _ReleaseThread)
t.Start()
If Not _ReleaseDone.WaitOne(3000, False) Then System.Diagnostics.Debug.WriteLine(Now & " Marx_libvlc_media_player_handle TIMEOUT")
handle = IntPtr.Zero
End If
Return True
End Function
Private Sub _ReleaseThread()
Try
libvlc_media_player_release(Me)
Catch
System.Diagnostics.Debug.WriteLine(Now & " Marx_libvlc_media_player_handle FAIL")
End Try
_ReleaseDone.Set()
End Sub
Return to “Development around libVLC”
Users browsing this forum: No registered users and 22 guests