]> git.sesse.net Git - vlc/commitdiff
Add sound volume, rate, and fullscreen support
authorRémi Denis-Courmont <rem@videolan.org>
Sat, 20 Oct 2007 16:02:03 +0000 (16:02 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Sat, 20 Oct 2007 16:02:03 +0000 (16:02 +0000)
bindings/cil/libvlc.cs
bindings/cil/marshal.cs
bindings/cil/testvlc.cs

index 78e809a11475f10b1563a53cd4f2f7e52ea1bdd3..7c38d6101ffc4ad611bc9bc9cf0938b291bdbbd7 100644 (file)
@@ -153,6 +153,9 @@ namespace VideoLAN.VLC
             }
         }
 
+        /**
+         * Switches to the next playlist item
+         */
         public void NextItem ()
         {
             CheckDisposed ();
@@ -162,6 +165,81 @@ namespace VideoLAN.VLC
             e.Consume ();
         }
 
+        /**
+         * Normalized audio output volume in percent (must be [0..100]).
+         */
+        public short SoundVolume
+        {
+            get
+            {
+                CheckDisposed ();
+
+                NativeException e = NativeException.Prepare ();
+                short vol = MediaControlAPI.SoundGetVolume (self, ref e);
+                e.Consume ();
+                return vol;
+            }
+            set
+            {
+                CheckDisposed ();
+
+                if ((value < 0) || (value > 100))
+                    throw new ArgumentOutOfRangeException ("Volume not within [0..100]");
+
+                NativeException e = NativeException.Prepare ();
+                MediaControlAPI.SoundSetVolume (self, value, ref e);
+                e.Consume ();
+            }
+        }
+
+        /**
+         * Performance speed rate in percent.
+         */
+        public int Rate
+        {
+            get
+            {
+                CheckDisposed ();
+
+                NativeException e = NativeException.Prepare ();
+                int rate = MediaControlAPI.GetRate (self, ref e);
+                e.Consume ();
+                return rate;
+            }
+            set
+            {
+                CheckDisposed ();
+
+                NativeException e = NativeException.Prepare ();
+                MediaControlAPI.SetRate (self, value, ref e);
+                e.Consume ();
+            }
+        }
+
+        /**
+         * Fullscreen flag.
+         */
+        public bool Fullscreen
+        {
+            get
+            {
+                CheckDisposed ();
+
+                NativeException e = NativeException.Prepare ();
+                int ret = MediaControlAPI.GetFullscreen (self, ref e);
+                e.Consume ();
+                return ret != 0;
+            }
+            set
+            {
+                CheckDisposed ();
+
+                NativeException e = NativeException.Prepare ();
+                MediaControlAPI.SetFullscreen (self, value ? 1 : 0, ref e);
+                e.Consume ();
+            }
+        }
+
         public void Dispose ()
         {
             self.Dispose ();
index bac4f88ce331e6261b037b5080235ee1668c2072..7a83465bb173cec561f03b1abc84ab402db1390b 100644 (file)
@@ -50,7 +50,22 @@ namespace VideoLAN.VLC
         public static extern IntPtr PlaylistGetList (MediaControlHandle self, ref NativeException e);
         [DllImport ("libvlc-control.dll", EntryPoint="mediacontrol_playlist_next_item")]
         public static extern void PlaylistNextItem (MediaControlHandle self, ref NativeException e);
-    }
+
+        [DllImport ("libvlc-control.dll", EntryPoint="mediacontrol_sound_get_volume")]
+        public static extern short SoundGetVolume (MediaControlHandle self, ref NativeException e);
+        [DllImport ("libvlc-control.dll", EntryPoint="mediacontrol_sound_set_volume")]
+        public static extern void SoundSetVolume (MediaControlHandle self, short volume, ref NativeException e);
+        /* SetVisual */
+
+        [DllImport ("libvlc-control.dll", EntryPoint="mediacontrol_get_rate")]
+        public static extern short GetRate (MediaControlHandle self, ref NativeException e);
+        [DllImport ("libvlc-control.dll", EntryPoint="mediacontrol_set_rate")]
+        public static extern void SetRate (MediaControlHandle self, int rate, ref NativeException e);
+        [DllImport ("libvlc-control.dll", EntryPoint="mediacontrol_get_fullscreen")]
+        public static extern int GetFullscreen (MediaControlHandle self, ref NativeException e);
+        [DllImport ("libvlc-control.dll", EntryPoint="mediacontrol_set_fullscreen")]
+        public static extern void SetFullscreen (MediaControlHandle self, int full, ref NativeException e);
+    };
 
     /**
      * Abstract safe handle class for non-NULL pointers
index 596bc8752bb6223c0123c8ed41d83371336bb5cf..7f61f33b46539d8daf5c436019908636d0b9a3ef 100644 (file)
@@ -34,11 +34,18 @@ namespace VideoLAN.VLC
             foreach (string s in args)
                 mc.AddItem (s);
 
+            Console.WriteLine ("Volume    : {0}%", mc.SoundVolume);
+            Console.WriteLine ("Rate      : {0}%", mc.Rate);
+            Console.WriteLine ("Fullscreen: {0}", mc.Fullscreen);
+            mc.Fullscreen = false;
+
             /*mc.Play ();*/
             Console.ReadLine ();
 
             mc.Stop ();
             mc.Clear ();
+            mc.SoundVolume = 100;
+            mc.Rate = 100;
 
             mc.Dispose ();
             return 0;