]> git.sesse.net Git - vlc/blob - bindings/cil/src/player.cs
Fix documentation
[vlc] / bindings / cil / src / player.cs
1 /**
2  * @file player.cs
3  * @brief Media player class
4  * @ingroup API
5  *
6  * @defgroup API Managed interface to LibVLC
7  * This is the primary class library for .NET applications
8  * to embed and control LibVLC.
9  *
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.
13  */
14
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.                                   *
21  *                                                                    *
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.              *
26  *                                                                    *
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  **********************************************************************/
31
32 using System;
33 using System.Runtime.InteropServices;
34
35 namespace VideoLAN.LibVLC
36 {
37    /**
38      * @brief MediaPlayerHandle: unmanaged LibVLC media player pointer
39      * @ingroup Internals
40      */
41     internal sealed class MediaPlayerHandle : NonNullHandle
42     {
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);
51
52         [DllImport ("libvlc.dll",
53                     EntryPoint="libvlc_media_player_release")]
54         internal static extern void Release (IntPtr ptr);
55
56         [DllImport ("libvlc.dll",
57                     EntryPoint="libvlc_media_player_set_media")]
58         internal static extern
59         MediaPlayerHandle SetMedia (MediaPlayerHandle player,
60                                     MediaHandle media,
61                                     NativeException ex);
62
63         protected override void Destroy ()
64         {
65             Release (handle);
66         }
67     };
68
69     /**
70      * @brief MediaPlayer: a simple media player
71      * @ingroup API
72      * Use this class to play a media.
73      */
74     public class MediaPlayer : BaseObject
75     {
76         internal MediaPlayerHandle Handle
77         {
78             get
79             {
80                 return handle as MediaPlayerHandle;
81             }
82         }
83
84         Media media; /**< Active media */
85         /**
86          * The Media object that the MediaPlayer is using,
87          * or null if there is none.
88          */
89         public Media Media
90         {
91             get
92             {
93                 return media;
94             }
95             set
96             {
97                 MediaHandle mh = (value != null) ? value.Handle : null;
98
99                 MediaPlayerHandle.SetMedia (Handle, mh, null);
100                 media = value;
101             }
102         }
103
104         /**
105          * Creates an empty MediaPlayer object.
106          * An input media will be needed before this media player can be used.
107          *
108          * @param instance VLC instance
109          */
110         public MediaPlayer (VLC instance)
111         {
112             this.media = null;
113             handle = MediaPlayerHandle.Create (instance.Handle, ex);
114             ex.Raise ();
115         }
116
117         /**
118          * Creates a MediaPlayer object from a Media object.
119          * This allows playing the specified media.
120          *
121          * @param media media object
122          */
123         public MediaPlayer (Media media)
124         {
125             this.media = media;
126             handle = MediaPlayerHandle.Create (media.Handle, ex);
127             ex.Raise ();
128         }
129
130     };
131 };