Table of Contents

Class LibVLC

Namespace
LibVLCSharp.Shared
Assembly
LibVLCSharp.dll

Main LibVLC API object representing a libvlc instance in native code. Note: You may create multiple mediaplayers from a single LibVLC instance

public class LibVLC : Internal, IDisposable
Inheritance
LibVLC
Implements
Inherited Members

Constructors

LibVLC(bool, bool, params string[])

Create and initialize a libvlc instance. This functions accept a list of "command line" arguments similar to the main(). These arguments affect the LibVLC instance default configuration. LibVLC may create threads. Therefore, any thread-unsafe process initialization must be performed before calling libvlc_new(). In particular and where applicable:

- setlocale() and textdomain(),

- setenv(), unsetenv() and putenv(),

(see also libvlc_media_player_set_xwindow()) and

- on Microsoft Windows, SetErrorMode().

- sigprocmask() shall never be invoked; pthread_sigmask() can be used.

On POSIX systems, the SIGCHLD signalmust notbe ignored, i.e. the signal handler must set to SIG_DFL or a function pointer, not SIG_IGN. Also while LibVLC is active, the wait() function shall not be called, and any call to waitpid() shall use a strictly positive value for the first parameter (i.e. the PID). Failure to follow those rules may lead to a deadlock or a busy loop. Also on POSIX systems, it is recommended that the SIGPIPE signal be blocked, even if it is not, in principles, necessary, e.g.: On Microsoft Windows Vista/2008, the process error mode SEM_FAILCRITICALERRORS flagmustbe set before using LibVLC. On later versions, that is optional and unnecessary. Also on Microsoft Windows (Vista and any later version), setting the default DLL directories to SYSTEM32 exclusively is strongly recommended for security reasons: Arguments are meant to be passed from the command line to LibVLC, just like VLC media player does. The list of valid arguments depends on the LibVLC version, the operating system and platform, and set of available LibVLC plugins. Invalid or unsupported arguments will cause the function to fail (i.e. return NULL). Also, some arguments may alter the behaviour or otherwise interfere with other LibVLC functions. There is absolutely no warranty or promise of forward, backward and cross-platform compatibility with regards to libvlc_new() arguments. We recommend that you do not use them, other than when debugging.

This will throw a VLCException if the native libvlc libraries cannot be found or loaded.

It may also throw a VLCException if the LibVLC and LibVLCSharp major versions do not match. See https://code.videolan.org/videolan/LibVLCSharp/-/blob/master/docs/versioning.md for more info about the versioning strategy.
public LibVLC(bool enableDebugLogs, bool useDefaultLibVLCOptions, params string[] options)

Parameters

enableDebugLogs bool

enable verbose debug logs

useDefaultLibVLCOptions bool

option to override default libvlc options defined by libvlcsharp. true to use default options, false to override

options string[]

list of arguments (should be NULL)

LibVLC(bool, params string[])

Create and initialize a libvlc instance. This functions accept a list of "command line" arguments similar to the main(). These arguments affect the LibVLC instance default configuration. LibVLC may create threads. Therefore, any thread-unsafe process initialization must be performed before calling libvlc_new(). In particular and where applicable:

- setlocale() and textdomain(),

- setenv(), unsetenv() and putenv(),

(see also libvlc_media_player_set_xwindow()) and

- on Microsoft Windows, SetErrorMode().

- sigprocmask() shall never be invoked; pthread_sigmask() can be used.

On POSIX systems, the SIGCHLD signalmust notbe ignored, i.e. the signal handler must set to SIG_DFL or a function pointer, not SIG_IGN. Also while LibVLC is active, the wait() function shall not be called, and any call to waitpid() shall use a strictly positive value for the first parameter (i.e. the PID). Failure to follow those rules may lead to a deadlock or a busy loop. Also on POSIX systems, it is recommended that the SIGPIPE signal be blocked, even if it is not, in principles, necessary, e.g.: On Microsoft Windows Vista/2008, the process error mode SEM_FAILCRITICALERRORS flagmustbe set before using LibVLC. On later versions, that is optional and unnecessary. Also on Microsoft Windows (Vista and any later version), setting the default DLL directories to SYSTEM32 exclusively is strongly recommended for security reasons: Arguments are meant to be passed from the command line to LibVLC, just like VLC media player does. The list of valid arguments depends on the LibVLC version, the operating system and platform, and set of available LibVLC plugins. Invalid or unsupported arguments will cause the function to fail (i.e. return NULL). Also, some arguments may alter the behaviour or otherwise interfere with other LibVLC functions. There is absolutely no warranty or promise of forward, backward and cross-platform compatibility with regards to libvlc_new() arguments. We recommend that you do not use them, other than when debugging.

This will throw a VLCException if the native libvlc libraries cannot be found or loaded.

It may also throw a VLCException if the LibVLC and LibVLCSharp major versions do not match. See https://code.videolan.org/videolan/LibVLCSharp/-/blob/master/docs/versioning.md for more info about the versioning strategy.
public LibVLC(bool enableDebugLogs, params string[] options)

Parameters

enableDebugLogs bool

enable verbose debug logs

options string[]

list of arguments (should be NULL)

LibVLC(params string[])

Create and initialize a libvlc instance. This functions accept a list of "command line" arguments similar to the main(). These arguments affect the LibVLC instance default configuration. LibVLC may create threads. Therefore, any thread-unsafe process initialization must be performed before calling libvlc_new(). In particular and where applicable:

- setlocale() and textdomain(),

- setenv(), unsetenv() and putenv(),

(see also libvlc_media_player_set_xwindow()) and

- on Microsoft Windows, SetErrorMode().

- sigprocmask() shall never be invoked; pthread_sigmask() can be used.

On POSIX systems, the SIGCHLD signalmust notbe ignored, i.e. the signal handler must set to SIG_DFL or a function pointer, not SIG_IGN. Also while LibVLC is active, the wait() function shall not be called, and any call to waitpid() shall use a strictly positive value for the first parameter (i.e. the PID). Failure to follow those rules may lead to a deadlock or a busy loop. Also on POSIX systems, it is recommended that the SIGPIPE signal be blocked, even if it is not, in principles, necessary, e.g.: On Microsoft Windows Vista/2008, the process error mode SEM_FAILCRITICALERRORS flagmustbe set before using LibVLC. On later versions, that is optional and unnecessary. Also on Microsoft Windows (Vista and any later version), setting the default DLL directories to SYSTEM32 exclusively is strongly recommended for security reasons: Arguments are meant to be passed from the command line to LibVLC, just like VLC media player does. The list of valid arguments depends on the LibVLC version, the operating system and platform, and set of available LibVLC plugins. Invalid or unsupported arguments will cause the function to fail (i.e. return NULL). Also, some arguments may alter the behaviour or otherwise interfere with other LibVLC functions. There is absolutely no warranty or promise of forward, backward and cross-platform compatibility with regards to libvlc_new() arguments. We recommend that you do not use them, other than when debugging.

This will throw a VLCException if the native libvlc libraries cannot be found or loaded.

It may also throw a VLCException if the LibVLC and LibVLCSharp major versions do not match. See https://code.videolan.org/videolan/LibVLCSharp/-/blob/master/docs/versioning.md for more info about the versioning strategy.
// example 
using var libvlc = new LibVLC("--verbose=2");
 // or 
using var libvlc = new LibVLC("--verbose", "2");
public LibVLC(params string[] options)

Parameters

options string[]

list of arguments, in the form "--option=value"

Properties

AudioFilters

Returns a list of audio filters that are available.

public ModuleDescription[] AudioFilters { get; }

Property Value

ModuleDescription[]

a list of module descriptions. It should be freed with libvlc_module_description_list_release().

In case of an error, NULL is returned.

Remarks

libvlc_module_description_t

libvlc_module_description_list_release

AudioOutputs

Gets the list of available audio output modules.

public AudioOutputDescription[] AudioOutputs { get; }

Property Value

AudioOutputDescription[]

list of available audio outputs. It must be freed with

Remarks

libvlc_audio_output_list_release

libvlc_audio_output_t .

In case of error, NULL is returned.

Changeset

The changeset of the LibVLC engine currently used by LibVLCSharp

public string Changeset { get; }

Property Value

string

Clock

Return the current time as defined by LibVLC. The unit is the microsecond. Time increases monotonically (regardless of time zone changes and RTC adjustments). The origin is arbitrary but consistent across the whole system (e.g. the system uptime, the time since the system was booted). On systems that support it, the POSIX monotonic clock is used.

public long Clock { get; }

Property Value

long

DialogHandlersSet

True if dialog handlers are set

public bool DialogHandlersSet { get; }

Property Value

bool

LastLibVLCError

A human-readable error message for the last LibVLC error in the calling thread. The resulting string is valid until another error occurs (at least until the next LibVLC call).

Null if no error.
public string? LastLibVLCError { get; }

Property Value

string

LibVLCCompiler

Retrieve the libvlc compiler version. Example: "gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu6)"

public string LibVLCCompiler { get; }

Property Value

string

RendererList

List of available renderers used to create RendererDiscoverer objects Note: LibVLC 3.0.0 and later

public RendererDescription[] RendererList { get; }

Property Value

RendererDescription[]

Version

The version of the LibVLC engine currently used by LibVLCSharp

public string Version { get; }

Property Value

string

VideoFilters

Returns a list of video filters that are available.

public ModuleDescription[] VideoFilters { get; }

Property Value

ModuleDescription[]

a list of module descriptions. It should be freed with libvlc_module_description_list_release().

In case of an error, NULL is returned.

Remarks

libvlc_module_description_t

libvlc_module_description_list_release

Methods

AddInterface(string?)

Try to start a user interface for the libvlc instance.

public bool AddInterface(string? name)

Parameters

name string

interface name, or null for default

Returns

bool

True if successful, false otherwise

AudioOutputDevices(string)

Gets a list of audio output devices for a given audio output module,

public AudioOutputDevice[] AudioOutputDevices(string audioOutputName)

Parameters

audioOutputName string

audio output name

(as returned by libvlc_audio_output_list_get())

Returns

AudioOutputDevice[]

A NULL-terminated linked list of potential audio output devices.

It must be freed with libvlc_audio_output_device_list_release()

Remarks

libvlc_audio_output_device_set().

Not all audio outputs support this. In particular, an empty (NULL)

list of devices doesnotimply that the specified audio output does

not work.

The list might not be exhaustive.

Some audio output devices in the list might not actually work in

some circumstances. By default, it is recommended to not specify any

explicit audio device.

LibVLC 2.1.0 or later.

ClearLibVLCError()

Clears the LibVLC error status for the current thread. This is optional. By default, the error status is automatically overridden when a new error occurs, and destroyed when the thread exits.

public void ClearLibVLCError()

CloseLogFile()

Close log file handle

public bool CloseLogFile()

Returns

bool

true if no file to close or close operation successful, false otherwise

Dispose(bool)

Dispose of this libvlc instance

protected override void Dispose(bool disposing)

Parameters

disposing bool

Equals(LibVLC)

Determines whether two object instances are equal.

protected bool Equals(LibVLC other)

Parameters

other LibVLC

other libvlc instance to compare with

Returns

bool

true if same instance, false otherwise

Equals(object?)

Determines whether two object instances are equal.

public override bool Equals(object? obj)

Parameters

obj object

other libvlc instance to compare with

Returns

bool

true if same instance, false otherwise

GetHashCode()

Returns the hashcode for this libvlc instance

public override int GetHashCode()

Returns

int

MediaDiscoverers(MediaDiscovererCategory)

Get media discoverer services by category

public MediaDiscovererDescription[] MediaDiscoverers(MediaDiscovererCategory discovererCategory)

Parameters

discovererCategory MediaDiscovererCategory

category of services to fetch

Returns

MediaDiscovererDescription[]

the number of media discoverer services (0 on error)

Remarks

LibVLC 3.0.0 and later.

SetAppId(string?, string?, string?)

Sets some meta-information about the application.

See also libvlc_set_user_agent().

public void SetAppId(string? id, string? version, string? icon)

Parameters

id string

Java-style application identifier, e.g. "com.acme.foobar"

version string

application version numbers, e.g. "1.2.3"

icon string

application icon name, e.g. "foobar"

Remarks

LibVLC 2.1.0 or later.

SetDialogHandlers(DisplayError, DisplayLogin, DisplayQuestion, DisplayProgress, UpdateProgress)

Register callbacks in order to handle VLC dialogs. LibVLC 3.0.0 and later.

public void SetDialogHandlers(DisplayError error, DisplayLogin login, DisplayQuestion question, DisplayProgress displayProgress, UpdateProgress updateProgress)

Parameters

error DisplayError

Called when an error message needs to be displayed.

login DisplayLogin

Called when a login dialog needs to be displayed. You can interact with this dialog by calling Dialog.PostLogin() to post an answer or Dialog.Dismiss() to cancel this dialog.

question DisplayQuestion

Called when a question dialog needs to be displayed. You can interact with this dialog by calling Dialog.PostLogin() to post an answer or Dialog.Dismiss() to cancel this dialog.

displayProgress DisplayProgress

Called when a progress dialog needs to be displayed.

updateProgress UpdateProgress

Called when a progress dialog needs to be updated.

SetExitHandler(ExitCallback)

Registers a callback for the LibVLC exit event. This is mostly useful if

the VLC playlist and/or at least one interface are started with

libvlc_playlist_play() or libvlc_add_intf() respectively.

Typically, this function will wake up your application main loop (from

another thread).

public void SetExitHandler(ExitCallback cb)

Parameters

cb ExitCallback

callback to invoke when LibVLC wants to exit,

or NULL to disable the exit handler (as by default)

Remarks

This function should be called before the playlist or interface are

started. Otherwise, there is a small race condition: the exit event could

be raised before the handler is registered.

This function and libvlc_wait() cannot be used at the same time.

SetLogFile(string)

Sets up logging to a file. Watch out: Overwrite contents if file exists! Potentially throws a VLCException if FILE * cannot be obtained

public void SetLogFile(string filename)

Parameters

filename string

open/create file with Write access. If existing, resets content.

Remarks

LibVLC 2.1.0 or later

SetUserAgent(string, string)

Sets the application name. LibVLC passes this as the user agent string

when a protocol requires it.

public void SetUserAgent(string name, string http)

Parameters

name string

human-readable application name, e.g. "FooBar player 1.2.3"

http string

HTTP User Agent, e.g. "FooBar/1.2.3 Python/2.6.0"

Remarks

LibVLC 1.1.1 or later

UnsetDialogHandlers()

Unset dialog callbacks if previously set

public void UnsetDialogHandlers()

Events

Log

The event that is triggered when a log is emitted from libVLC. Listening to this event will discard the default logger in libvlc.

public event EventHandler<LogEventArgs> Log

Event Type

EventHandler<LogEventArgs>

Operators

operator ==(LibVLC?, LibVLC?)

Determines whether 2 instances of libvlc are equals

public static bool operator ==(LibVLC? libvlc1, LibVLC? libvlc2)

Parameters

libvlc1 LibVLC

1st instance of libvlc

libvlc2 LibVLC

2nd instance of libvlc

Returns

bool

operator !=(LibVLC?, LibVLC?)

Determines whether 2 instances of libvlc are different

public static bool operator !=(LibVLC? libvlc1, LibVLC? libvlc2)

Parameters

libvlc1 LibVLC

1st instance of libvlc

libvlc2 LibVLC

2nd instance of libvlc

Returns

bool