]> git.sesse.net Git - vlc/blobdiff - bindings/cil/tests/testvlc.cs
More macro parametrization.
[vlc] / bindings / cil / tests / testvlc.cs
index 1e0c9c20e2c06c93298236dee05be587d6499eeb..9ea8a3188a32cc14da8b0b0b501b6dfc8b68deb6 100644 (file)
@@ -30,9 +30,29 @@ namespace VideoLAN.LibVLC.Test
     {
         private static void DumpMedia (Media m)
         {
-            Console.WriteLine ("Media at    {0}", m.Location);
-            Console.WriteLine (" duration:  {0}µs", m.Duration);
-            Console.WriteLine (" preparsed: {0}", m.IsPreparsed);
+            Console.WriteLine ("Media: {0} {1} (duration: {2}, {3}preparsed)",
+                               m.State, m.Location, m.Duration,
+                               m.IsPreparsed ? "" : "not ");
+        }
+
+        private static void WriteMediaState (Media m, State s)
+        {
+            Console.WriteLine (" -> {0}", s);
+        }
+
+        private static void DumpPlayer (Player p)
+        {
+            if (!p.IsPlaying)
+                return;
+
+            int percent = (int)(p.Position * 100);
+            Console.Write ("{0}: {1} of {2} ms ({3}%)\r", p.State,
+                           p.Time, p.Length, percent);
+        }
+
+        private static void Sleep (int msec)
+        {
+            System.Threading.Thread.Sleep (msec);
         }
 
         public static int Main (string[] args)
@@ -46,13 +66,35 @@ namespace VideoLAN.LibVLC.Test
             Console.WriteLine (" (compiled with {0})", VLC.Compiler);
 
             VLC vlc = new VLC (argv);
-            Media m = new Media (vlc, "/dev/null");
-            DumpMedia (m);
+            foreach (string mrl in args)
+            {
+                Media media = new Media (vlc, mrl);
+                Player player = new Player (media);
+
+                DumpMedia (media);
+                DumpMedia ((Media)media.Clone ());
+                media.StateChanged += WriteMediaState;
+
+                /*foreach (MetaType type in Enum.GetValues (typeof (MetaType)))
+                {
+                    string meta = media.GetMeta (type);
+                    if (meta != null)
+                        Console.WriteLine (" {0}: {1}", type, meta);
+                }*/
 
-            DumpMedia ((Media)m.Clone ());
+                player.Play ();
+                do
+                {
+                    DumpPlayer (player);
+                    Sleep (500);
+                }
+                while (player.IsPlaying);
+                player.Stop ();
+                media.Dispose ();
+                player.Dispose ();
+            }
 
             vlc.Dispose ();
-            m.Dispose ();
             return 0;
         }
     };