.Net Interface to VLC

From VideoLAN Wiki
Revision as of 01:36, 1 January 2007 by Tappen (talk | contribs)
Jump to navigation Jump to search

Work from Tappen and Odyssee on the forum.

I started with Odysee's work [1] and wrote a .Net user control that uses libvlc interfaces to do what the ActiveX control does and more, like getting info about and getting/setting audio and subtitle tracks, aspect ratios, deinterlacing filters and more. This compiles in Visual C#.Net Express, free from Microsoft [2].

Tappen


IPlayer.cs is the main Interface supported by VlcUserControl, since something like this deserves the Bridge pattern treatment. IPlayer.cs should really be in a different assembly from the control to allow other controls to support it and be used interchange-ably with VlcUserControl but that's up to you developers.

NativeLibVlc.cs contains the .Net Interop versions of the native VLC C++ structures and functions, and a class which wraps these calls in C#.

VlcUserControl.cs contains the non-designer part of the VlcUserControl class, derived from System.Windows.Forms.UserControl, which can be used either directly on C# forms, or as an ActiveX control if wrapped and registered in a dll. VlcUserControl acts mostly as a wrapper for the NativeLibVlc.cs functions, but also has a few complications such as allowing multiple playback position moves in quick succession or when paused, since VLC, as an asynchronous player, will not return the correct position for a significant part of a second after a move. VlcUserControl also handles (optionally, default is on, variable bool useVlcCrop) cropping instead of using the VLC cropping feature, (see InnerVlcWindow.cs comment below for explanation). Thirdly, VlcUserControl attempts to minimize the inaccuracy of moving by timestamp in Mpeg-2 files since VLC doesn't do this well (optional, default is off, variable bool useMpegVbrOffset).

VlcUserControl.Designer.cs contains the designer part of the VlcUserControl class.

VlcUserControl.resx contains the layout and resource definition of the VlcUserControl class.

InnerVlcWindow.cs is an essentially empty class. One instance is created as a child window by each VlcUserControl class instance where VLC will actually draw the video. This allows VlcUserControl to act as a "viewport" and crop the VLC output since the cropping filter of VLC leaves something to be desired when used in a player application (it can't co-exist with DeInterlace filters most importantly).

InnerVlcWindow.Designer.cs contains the designer part of the InnerVlcWindow class.

AssemblyInfo.cs is an optional file containing sample assembly information if the above classes are placed in a separate dll module in your code hierarchy. As usual in .Net 2.0 projects, it should be placed in a sub-directory named "Properties".

VLanControl.csproj is an optional project file for all the above files.