Changeset 8837d3d6ac772535558a22e8cc750d2497f126d5
- Timestamp:
- 10/21/07 18:52:11 (11 months ago)
- git-parent:
- Files:
-
- bindings/cil/libvlc.cs (modified) (5 diffs)
- bindings/cil/testvlc.cs (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
bindings/cil/libvlc.cs
r9c4f520 r8837d3d 23 23 24 24 using System; 25 using System.Collections.Generic; 25 26 using System.Runtime.InteropServices; 26 27 … … 70 71 public class Instance : BaseObject<InstanceHandle> 71 72 { 73 Dictionary<int, PlaylistItem> items; 74 72 75 internal Instance (InstanceHandle self) : base (self) 73 76 { 77 items = new Dictionary<int, PlaylistItem> (); 74 78 } 75 79 … … 82 86 return new MediaDescriptor (dh); 83 87 } 84 85 88 86 89 [DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_loop")] … … 170 173 PlaylistClear (self, ex); 171 174 ex.Raise (); 175 176 foreach (PlaylistItem item in items.Values) 177 item.Close (); 178 items.Clear (); 172 179 } 173 180 174 181 [DllImport ("libvlc-control.dll", 175 182 EntryPoint="libvlc_playlist_add_extended")] 176 static extern voidPlaylistAdd (InstanceHandle self, U8String uri,177 U8String name, int optc,178 U8String[] optv, NativeException e);183 static extern int PlaylistAdd (InstanceHandle self, U8String uri, 184 U8String name, int optc, 185 U8String[] optv, NativeException e); 179 186 /** Appends an item to the playlist with options */ 180 public voidAdd (string mrl, string name, string[] opts)187 public PlaylistItem Add (string mrl, string name, string[] opts) 181 188 { 182 189 U8String umrl = new U8String (mrl); … … 186 193 optv[i] = new U8String (opts[i]); 187 194 188 PlaylistAdd (self, umrl, uname, optv.Length, optv, ex); 189 ex.Raise (); 190 } 191 public void Add (string mrl, string[] opts) 192 { 193 Add (mrl, null, opts); 194 } 195 public void Add (string mrl, string name) 196 { 197 Add (mrl, name, new string[0]); 198 } 199 public void Add (string mrl) 200 { 201 Add (mrl, null, new string[0]); 195 int id = PlaylistAdd (self, umrl, uname, optv.Length, optv, ex); 196 ex.Raise (); 197 198 PlaylistItem item = new PlaylistItem (id); 199 items.Add (id, item); 200 return item; 201 } 202 public PlaylistItem Add (string mrl, string[] opts) 203 { 204 return Add (mrl, null, opts); 205 } 206 public PlaylistItem Add (string mrl, string name) 207 { 208 return Add (mrl, name, new string[0]); 209 } 210 public PlaylistItem Add (string mrl) 211 { 212 return Add (mrl, null, new string[0]); 213 } 214 215 [DllImport ("libvlc-control.dll", 216 EntryPoint="libvlc_playlist_delete_item")] 217 static extern int PlaylistDelete (InstanceHandle self, int id, 218 NativeException e); 219 public void Delete (PlaylistItem item) 220 { 221 int id = item.Id; 222 PlaylistDelete (self, id, ex); 223 ex.Raise (); 224 225 item.Close (); 226 items.Remove (id); 227 } 228 }; 229 230 public class PlaylistItem 231 { 232 int id; 233 bool deleted; 234 235 internal PlaylistItem (int id) 236 { 237 this.id = id; 238 this.deleted = false; 239 } 240 241 internal void Close () 242 { 243 deleted = true; 244 } 245 246 internal int Id 247 { 248 get 249 { 250 if (deleted) 251 throw new ObjectDisposedException ("Playlist item deleted"); 252 return id; 253 } 202 254 } 203 255 }; bindings/cil/testvlc.cs
r54f91fa r8837d3d 37 37 md.Dispose (); 38 38 39 PlaylistItem item = null; 40 39 41 foreach (string s in args) 40 vlc.Add (s);42 item = vlc.Add (s); 41 43 42 44 vlc.Loop = false; 43 45 vlc.TogglePause (); 44 46 Console.ReadLine (); 47 48 if (item != null) 49 vlc.Delete (item); 50 vlc.Clear (); 45 51 vlc.Dispose (); 46 52 return 0;
