.NET Interface: Get Current Byte Position

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.
klk
New Cone
New Cone
Posts: 6
Joined: 24 Nov 2007 09:15

.NET Interface: Get Current Byte Position

Postby klk » 23 May 2008 06:18

Hi,

I want to add a method to NativeLib.cs that returns the player's current byte position. I wrote the following .NET code to facilitate this:

Code: Select all

public int CurrentBytePosition() { if (!this.ProducingEvents) { this.ProducingEvents = true; } IntPtr resultString = IntPtr.Zero; NativeLib thisVlc = (NativeLib)this.gch.Target; using (VlcObject vobj = new VlcObject(thisVlc.vlcHandle, ObjectType.VLC_OBJECT_INPUT)) { if (vobj.SubObject != IntPtr.Zero) { input_Control(vobj.SubObject, input_query_e.INPUT_GET_BYTE_POSITION, Meta_information, Now_Playing, ref resultString); } } return resultString.ToInt32(); }
However, it always returns 0. Any ideas on what I am doing wrong?

Thanks,

klk

dsanghera
New Cone
New Cone
Posts: 4
Joined: 27 Nov 2007 02:59

Re: .NET Interface: Get Current Byte Position

Postby dsanghera » 23 May 2008 10:57

Interesting, I have this same question!

dsanghera
New Cone
New Cone
Posts: 4
Joined: 27 Nov 2007 02:59

Re: .NET Interface: Get Current Byte Position

Postby dsanghera » 24 May 2008 00:11

Any takers?!

twilight tinker
New Cone
New Cone
Posts: 5
Joined: 25 May 2008 15:45
Location: San Francisco, CA

Re: .NET Interface: Get Current Byte Position

Postby twilight tinker » 25 May 2008 16:19

Hi,

You code will work but only on certain file types. VLC must have a file type that it can read this information from or the return value is 0.

I have a LOT of experience with several different C# .NET Inferfaces and several Managed C++ .NET Interfaces to VLC and ALL of the sample source code published and referenced on this website and on other website will NOT work in a production environment. Let me explain, all of the sample source code creates a STATIC link to the vlc library and this is NOT correct and makes the interface useless in the real world. Take for example, a camera wall where you want to include say 36 instances of VLC playing at the same time, if you have a static linkagage it just won't work!

The first step is to re-write the static link in the code you have so that you are always creating a NEW instance of the .NET vlc interface. This means that you can't use the trick of calling "vlc"quit" to shut down the interface any longer but there are other ways to shut down all the VLC threads.

For example, remove this:
static NativeLibVlc()
{
...
}
This will prevent you from creating multiple instances of the control that will work correctly in structures like camera walls.
I am amazed that anyone would be so stupid as to create a static instance to the library !!!! Very bad coding! This library instance must NEVER be made static!

Next, and most important, is to NEVER use ":vout=vout_directx".... NEVER set the output to DirectX !!!!
All of the sample source cod efor .NET Interfaces do this and it is WRONG---do NOT do it!

You must set the video to Open GL as follows: "--vout=opengl"

Why? Only Open GL can lock the video to the window and hold the video so it isn't lost. Let me explain, create a form and place instances of VLC on that form, then collapse that form or move it around the screen so part of goes below the bottom of the screem and you will notice that one of the instances of VLC no longer is player video and that it is corrupted and won't play video correctly any more.

In order to use VLC in a camera wall or multiple instances of VLC you MUST use Open GL and NEVER DirectX.
There are at least a dozen other reasons why you should never use DirectX and always use Open GL that I won'y go into here but I can only guess that the people who wrote those samples either didn't undrstand this or they wanted to keep this secret to themselves!

Hope this helps you with you .NET interfaces to VLC


Return to “VLC media player for Windows Troubleshooting”

Who is online

Users browsing this forum: Bing [Bot] and 39 guests