3 * @brief LibVLC instance class
6 * @defgroup API Managed interface to LibVLC
8 * This is the primary class library for .NET applications
9 * to embed and control LibVLC.
12 /**********************************************************************
13 * Copyright (C) 2007-2009 RĂ©mi Denis-Courmont. *
14 * This program is free software; you can redistribute and/or modify *
15 * it under the terms of the GNU General Public License as published *
16 * by the Free Software Foundation; version 2 of the license, or (at *
17 * your option) any later version. *
19 * This program is distributed in the hope that it will be useful, *
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
22 * See the GNU General Public License for more details. *
24 * You should have received a copy of the GNU General Public License *
25 * along with this program; if not, you can get it from: *
26 * http://www.gnu.org/copyleft/gpl.html *
27 **********************************************************************/
30 using System.Runtime.InteropServices;
33 * @brief VideoLAN.LibVLC: VideoLAN project's LibVLC .Net bindings
36 * This namespace provides a set of managed APIs around the native LibVLC
37 * for the .Net Common Language Runtime.
39 namespace VideoLAN.LibVLC
42 * @brief InstanceHandle: unmanaged LibVLC instance pointer
45 internal sealed class InstanceHandle : NonNullHandle
48 * NonNullHandle.Destroy
50 protected override void Destroy ()
52 LibVLC.Release (handle, null);
57 * @brief VLC: VLC media player instance
60 * The VLC class provides represent a run-time instance of a media player.
61 * An instance can spawn multiple independent medias, however
62 * configuration settings, message logging, etc are common to all medias
63 * from the same instance.
65 public class VLC : BaseObject
67 internal InstanceHandle Handle
71 return handle as InstanceHandle;
76 * Loads the native LibVLC and creates a LibVLC instance.
78 * @param args VLC command line parameters for the LibVLC Instance.
80 public VLC (string[] args)
82 U8String[] argv = new U8String[args.Length];
83 for (int i = 0; i < args.Length; i++)
84 argv[i] = new U8String (args[i]);
86 handle = LibVLC.Create (argv.Length, argv, ex);
91 * Starts a VLC interface plugin.
93 * @param name name of the interface plugin (e.g. "http", "qt4", ...)
95 public void AddInterface (string name)
97 U8String uname = new U8String (name);
99 LibVLC.AddIntf (Handle, uname, ex);
104 * Waits until VLC instance exits. This can happen if a fatal error
105 * occurs (e.g. cannot parse the arguments), if the user has quit
106 * through an interface, or if the special vlc://quit item was played.
110 LibVLC.Wait (Handle);
114 * The human-readable LibVLC version number.
116 public static string Version
120 return U8String.FromNative (LibVLC.GetVersion ());
125 * The human-readable LibVLC C compiler infos.
127 public static string Compiler
131 return U8String.FromNative (LibVLC.GetCompiler ());
136 * The unique commit identifier from the LibVLC source control system,
137 * or "exported" if unknown.
139 public static string ChangeSet
143 return U8String.FromNative (LibVLC.GetChangeset ());
148 * The unmanaged VLC-internal instance object.
149 * Do not use this unless you really know what you are doing.
151 public SafeHandle Object
155 return LibVLC.GetVLCInstance (Handle);
162 * @mainpage libvlc-cil documentation
164 * @section Introduction
166 * libvlc-cil is a thin API layer around LibVLC,
167 * the VideoLAN's project media framework C library.
168 * LibVLC comes built-in the VLC media player.
170 * With libvlc-cil, you can use LibVLC
171 * from within the .Net Common Language Runtime,
172 * with the CIL programming language of your preference.
173 * However, libvlc-cil and the code sample in this documentation
176 * @section Installation
178 * libvlc-cil does <b>not</b> include the underlying LibVLC by default.
179 * Make sure VLC, or at least LibVLC and the relevant VLC plugins are present.
180 * The LibVLC runtime library needs to be in the library search path for the
181 * Common Language Runtime. Check the documentation for your CLR for details.
183 * On Windows, libvlc.dll needs to be in the current directory, the DLL path
184 * of the running process, or the system search path (but the latter is
185 * uncommon and not supported by the official LibVLC installer).
187 * On Linux, libvlc.so should be in /usr/lib; if it is in another directory,
188 * such as /usr/local/lib, you might need to add that directory to the
189 * LD_LIBRARY_PATH environment variable.
193 * First, you need to create a VLC instance. This will load and setup the
194 * native VLC runtime, the VLC configuration, the list of available plugins,
195 * the platform adaptation and the VLC log messages and objects subsystems
198 * using VideoLAN.LibVLC;
202 * Console.WriteLine("Running on VLC version {0}", VLC.Version);
204 * catch (Exception e) {
205 * Console.WriteLine("VLC is not available on your system.");
209 * string[] args = new string[]{ "-v", "--ignore-config" };
210 * VLC vlc = new VLC(args);
212 * @see VideoLAN::LibVLC::VLC
214 * To play media, you need a media and a player.
216 * Media media = new Media(vlc, "http://www.example.com/video.ogv");
217 * Player player = new Player(media);
220 * @see VideoLAN::LibVLC::Media @see VideoLAN::LibVLC::Player
222 * All these objects use unmanaged resources.
223 * They all implement the IDisposeable interface.
224 * You should dispose them when you do not need them anymore: