]> git.sesse.net Git - vlc/commitdiff
Basic playlist controls
authorRémi Denis-Courmont <rem@videolan.org>
Sun, 21 Oct 2007 12:55:32 +0000 (12:55 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Sun, 21 Oct 2007 12:55:32 +0000 (12:55 +0000)
bindings/cil/libvlc.cs
bindings/cil/testvlc.cs
bindings/cil/ustring.cs

index 0bd4cebf2ec527476ca8e375115d071a3c1a1675..f460831062ba3ca6c4bd3d55fbdf7b848ded097b 100644 (file)
@@ -64,6 +64,9 @@ namespace VideoLAN.LibVLC
         }
     };
 
+    /**
+     * Managed class for LibVLC instance (including playlist)
+     */
     public class Instance : BaseObject<InstanceHandle>
     {
         internal Instance (InstanceHandle self) : base (self)
@@ -78,6 +81,113 @@ namespace VideoLAN.LibVLC
 
             return new MediaDescriptor (dh);
         }
+
+
+        [DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_loop")]
+        static extern void PlaylistLoop (InstanceHandle self, int b,
+                                         NativeException ex);
+        /** Sets the playlist loop flag */
+        public bool Loop
+        {
+            set
+            {
+                PlaylistLoop (self, value ? 1 : 0, ex);
+                ex.Raise ();
+            }
+        }
+
+        [DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_play")]
+        static extern void PlaylistPlay (InstanceHandle self, int id, int optc,
+                                         U8String[] optv, NativeException ex);
+        /** Plays the next playlist item */
+        public void Play ()
+        {
+            PlaylistPlay (self, -1, 0, new U8String[0], ex);
+            ex.Raise ();
+        }
+
+        [DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_pause")]
+        static extern void PlaylistPause (InstanceHandle self,
+                                          NativeException ex);
+        /** Toggles pause */
+        public void TogglePause ()
+        {
+            PlaylistPause (self, ex);
+            ex.Raise ();
+        }
+
+        [DllImport ("libvlc-control.dll",
+                    EntryPoint="libvlc_playlist_isplaying")]
+        static extern int PlaylistIsPlaying (InstanceHandle self,
+                                             NativeException ex);
+        /** Whether the playlist is running, or in pause/stop */
+        public bool IsPlaying
+        {
+            get
+            {
+                int ret = PlaylistIsPlaying (self, ex);
+                ex.Raise ();
+                return ret != 0;
+            }
+        }
+
+        [DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_stop")]
+        static extern void PlaylistStop (InstanceHandle self,
+                                         NativeException ex);
+        /** Stops playing */
+        public void Stop ()
+        {
+            PlaylistStop (self, ex);
+            ex.Raise ();
+        }
+
+        [DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_next")]
+        static extern void PlaylistNext (InstanceHandle self,
+                                         NativeException ex);
+        /** Goes to next playlist item (and start playing it) */
+        public void Next ()
+        {
+            PlaylistNext (self, ex);
+            ex.Raise ();
+        }
+
+        [DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_prev")]
+        static extern void PlaylistPrev (InstanceHandle self,
+                                         NativeException ex);
+        /** Goes to previous playlist item (and start playing it) */
+        public void Prev ()
+        {
+            PlaylistPrev (self, ex);
+            ex.Raise ();
+        }
+
+        [DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_clear")]
+        static extern void PlaylistClear (InstanceHandle self,
+                                          NativeException ex);
+        /** Clears the whole playlist */
+        public void Clear ()
+        {
+            PlaylistClear (self, ex);
+            ex.Raise ();
+        }
+
+        [DllImport ("libvlc-control.dll", EntryPoint="libvlc_playlist_add")]
+        static extern void PlaylistAdd (InstanceHandle self, U8String uri,
+                                        U8String name, NativeException e);
+        /** Appends an item to the playlist */
+        public void Add (string mrl)
+        {
+            Add (mrl, null);
+        }
+        /** Appends an item to the playlist */
+        public void Add (string mrl, string name)
+        {
+            U8String umrl = new U8String (mrl);
+            U8String uname = new U8String (name);
+
+            PlaylistAdd (self, umrl, uname, ex);
+            ex.Raise ();
+        }
     };
 
     /** Safe handle for unmanaged LibVLC media descriptor */
index 4fa204b55414c8e8bb5c8817775933892d734900..43219d31b976297ef650f92cc3322452d386bf9d 100644 (file)
@@ -34,8 +34,14 @@ namespace VideoLAN.LibVLC.Test
 
             Instance vlc = VLC.CreateInstance (argv);
             MediaDescriptor md = vlc.CreateDescriptor (args[0]);
-
             md.Dispose ();
+
+            foreach (string s in args)
+                vlc.Add (s);
+
+            vlc.Loop = false;
+            vlc.TogglePause ();
+            Console.ReadLine ();
             vlc.Dispose ();
             return 0;
         }
index e64d53dadc0379fc1f50076097b8219bc38bf445..7175d00b953d1981e40cc64b39d76b2e0b3bd3cd 100644 (file)
@@ -36,6 +36,9 @@ namespace VideoLAN.LibVLC
 
         public U8String (string value)
         {
+            if (value == null)
+                return;
+
             byte[] bytes = System.Text.Encoding.UTF8.GetBytes (value);
             mb_str = new byte[bytes.Length + 1];
             Array.Copy (bytes, mb_str, bytes.Length);