]> git.sesse.net Git - vlc/blob - bindings/cil/libvlc.cs
Embryonic CIL bindings for libvlc-control
[vlc] / bindings / cil / libvlc.cs
1 /*
2  * libvlc.cs - libvlc-control CIL bindings
3  *
4  * $Id$
5  */
6
7 /**********************************************************************
8  *  Copyright (C) 2007 RĂ©mi Denis-Courmont.                           *
9  *  This program is free software; you can redistribute and/or modify *
10  *  it under the terms of the GNU General Public License as published *
11  *  by the Free Software Foundation; version 2 of the license, or (at *
12  *  your option) any later version.                                   *
13  *                                                                    *
14  *  This program is distributed in the hope that it will be useful,   *
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of    *
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.              *
17  *  See the GNU General Public License for more details.              *
18  *                                                                    *
19  *  You should have received a copy of the GNU General Public License *
20  *  along with this program; if not, you can get it from:             *
21  *  http://www.gnu.org/copyleft/gpl.html                              *
22  **********************************************************************/
23
24 using System;
25 using System.Runtime.InteropServices;
26
27 namespace VideoLAN.VLC
28 {
29
30     public class MediaControl : IDisposable
31     {
32         /**
33          * Possible player status
34          */
35         enum PlayerStatus
36         {
37             PlayingStatus,
38             PauseStatus,
39             ForwardStatus,
40             BackwardStatus,
41             InitStatus,
42             EndStatus,
43             UndefinedStatus,
44         };
45
46         enum PositionOrigin
47         {
48             AbsolutePosition,
49             RelativePosition,
50             ModuloPosition,
51         };
52
53         enum PositionKey
54         {
55             ByteCount,
56             SampleCount,
57             MediaTime,
58         };
59
60         MediaControlHandle self;
61
62         private void CheckDisposed ()
63         {
64             if (self.IsInvalid)
65                 throw new ObjectDisposedException ("Media controlled disposed");
66         }
67
68         /**
69          * Creates a MediaControl with a new LibVLC instance
70          */
71         public MediaControl (string[] args)
72         {
73             NativeException e = NativeException.Prepare ();
74
75             U8String[] argv = new U8String[args.Length];
76             for (int i = 0; i < args.Length; i++)
77                 argv[i] = new U8String (args[i]);
78
79             self = MediaControlAPI.New (argv.Length, argv, ref e);
80             e.Consume ();
81         }
82
83         /**
84          * Creates a MediaControl from an existing LibVLC instance
85          */
86         /*public MediaControl (MediaControl instance)
87         {
88             NativeException e = NativeException.Prepare ();
89             IntPtr libvlc = mediacontrol_get_libvlc_instance (instance.self);
90
91             self = mediacontrol_new_from_instance (libvlc, ref e);
92             e.Consume ();
93         }*/
94
95         /*public void Play (from)
96         {
97             CheckDisposed ();
98             throw new NotImplementedException ();
99         }*/
100
101         public void Resume ()
102         {
103             CheckDisposed ();
104             NativeException e = NativeException.Prepare ();
105
106             MediaControlAPI.Resume (self, IntPtr.Zero, ref e);
107             e.Consume ();
108         }
109
110         public void Pause ()
111         {
112             CheckDisposed ();
113             NativeException e = NativeException.Prepare ();
114
115             MediaControlAPI.Pause (self, IntPtr.Zero, ref e);
116             e.Consume ();
117         }
118
119         public void Stop ()
120         {
121             CheckDisposed ();
122
123             NativeException e = NativeException.Prepare ();
124             MediaControlAPI.Stop (self, IntPtr.Zero, ref e);
125             e.Consume ();
126         }
127
128         public void AddItem (string mrl)
129         {
130             CheckDisposed ();
131
132             U8String nmrl = new U8String (mrl);
133             NativeException e = NativeException.Prepare ();
134             MediaControlAPI.PlaylistAddItem (self, nmrl, ref e);
135             e.Consume ();
136         }
137
138         public void Clear ()
139         {
140             CheckDisposed ();
141
142             NativeException e = NativeException.Prepare ();
143             MediaControlAPI.PlaylistClear (self, ref e);
144             e.Consume ();
145         }
146
147         public string[] Playlist
148         {
149             get
150             {
151                 CheckDisposed ();
152                 throw new NotImplementedException ();
153             }
154         }
155
156         public void NextItem ()
157         {
158             CheckDisposed ();
159
160             NativeException e = NativeException.Prepare ();
161             MediaControlAPI.PlaylistNextItem (self, ref e);
162             e.Consume ();
163         }
164
165         public void Dispose ()
166         {
167             self.Dispose ();
168         }
169     };
170 };