3 * @brief Media player class
6 * @defgroup API Managed interface to LibVLC
7 * This is the primary class library for .NET applications
8 * to embed and control LibVLC.
10 * @defgroup Internals LibVLC internals
11 * This covers internal marshalling functions to use the native LibVLC.
12 * Only VLC developpers should need to read this section.
15 /**********************************************************************
16 * Copyright (C) 2009 RĂ©mi Denis-Courmont. *
17 * This program is free software; you can redistribute and/or modify *
18 * it under the terms of the GNU General Public License as published *
19 * by the Free Software Foundation; version 2 of the license, or (at *
20 * your option) any later version. *
22 * This program is distributed in the hope that it will be useful, *
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
25 * See the GNU General Public License for more details. *
27 * You should have received a copy of the GNU General Public License *
28 * along with this program; if not, you can get it from: *
29 * http://www.gnu.org/copyleft/gpl.html *
30 **********************************************************************/
33 using System.Runtime.InteropServices;
35 namespace VideoLAN.LibVLC
38 * @brief MediaPlayerHandle: unmanaged LibVLC media player pointer
41 internal sealed class MediaPlayerHandle : NonNullHandle
43 [DllImport ("libvlc.dll",
44 EntryPoint="libvlc_media_player_new")]
45 internal static extern
46 MediaPlayerHandle Create (InstanceHandle inst, NativeException ex);
47 [DllImport ("libvlc.dll",
48 EntryPoint="libvlc_media_player_new_from_media")]
49 internal static extern
50 MediaPlayerHandle Create (MediaHandle media, NativeException ex);
52 [DllImport ("libvlc.dll",
53 EntryPoint="libvlc_media_player_release")]
54 internal static extern void Release (IntPtr ptr);
56 [DllImport ("libvlc.dll",
57 EntryPoint="libvlc_media_player_set_media")]
58 internal static extern
59 MediaPlayerHandle SetMedia (MediaPlayerHandle player,
63 protected override void Destroy ()
70 * @brief MediaPlayer: a simple media player
71 * Use this class to play a media.
73 public class MediaPlayer : BaseObject
75 internal MediaPlayerHandle Handle
79 return handle as MediaPlayerHandle;
83 Media media; /**< Active media */
85 * The Media object that the MediaPlayer is using,
86 * or null if there is none.
96 MediaHandle mh = (value != null) ? value.Handle : null;
98 MediaPlayerHandle.SetMedia (Handle, mh, null);
104 * Creates an empty MediaPlayer object.
105 * An input media will be needed before this media player can be used.
107 * @param instance VLC instance
109 public MediaPlayer (VLC instance)
112 handle = MediaPlayerHandle.Create (instance.Handle, ex);
117 * Creates a MediaPlayer object from a Media object.
118 * This allows playing the specified media.
120 * @param media media object
122 public MediaPlayer (Media media)
125 handle = MediaPlayerHandle.Create (media.Handle, ex);