]> git.sesse.net Git - vlc/commitdiff
Extend Media class
authorRémi Denis-Courmont <rdenis@simphalempin.com>
Sat, 21 Feb 2009 15:10:02 +0000 (17:10 +0200)
committerRémi Denis-Courmont <rdenis@simphalempin.com>
Sat, 21 Feb 2009 16:15:09 +0000 (18:15 +0200)
bindings/cil/src/libvlc.cs
bindings/cil/src/media.cs

index 1728cc95bee44004b8558fa02327499edff651c7..157a32b38c7f9ba92fe1a1c19e46ec3d97ebec70 100644 (file)
@@ -117,7 +117,7 @@ namespace VideoLAN.LibVLC
         public static extern
         MediaListHandle MediaSubItems (MediaHandle media, NativeException ex);*/
 
-        /*[DllImport ("libvlc.dll", EntryPoint="libvlc_media_get_state")]
+        /*[DllImport ("libvlc.dll", EntryPoint="libvlc_media_event_manager")]
         public static extern
         EventManagerHandle MediaGetEventManager (MediaHandle media,
                                                  NativeException ex);*/
index 3a001b4324cad51e4499bd89e2a09f1490ea52e6..18d6b784b59ee2e9756c0cd0b78170d2771fd519 100644 (file)
@@ -47,7 +47,7 @@ namespace VideoLAN.LibVLC
      * @ingroup API
      * Each media object represents an input media, such as a file or an URL.
      */
-    public class Media : BaseObject
+    public class Media : BaseObject, ICloneable
     {
         internal MediaHandle Handle
         {
@@ -94,5 +94,61 @@ namespace VideoLAN.LibVLC
                 LibVLC.MediaAddUntrustedOption (Handle, uopts, ex);
             Raise ();
         }
+
+        /**
+         * The media location (file path, URL, ...).
+         */
+        public string Location
+        {
+            get
+            {
+                MemoryHandle str = LibVLC.MediaGetMRL (Handle, ex);
+                Raise ();
+                return str.Transform ();
+            }
+        }
+
+        private Media (MediaHandle handle)
+        {
+            this.handle = handle;
+        }
+
+        /**
+         * Duplicates a media object.
+         */
+        public object Clone ()
+        {
+            return new Media (LibVLC.MediaDuplicate (Handle));
+        }
+
+        /**
+         * Duration of the media in microseconds. The precision of the result
+         * depends on the input stram protocol and file format. The value
+         * might be incorrect and unknown (VLC usually returns 0 then).
+         */
+        public long Duration
+        {
+            get
+            {
+                long duration = LibVLC.MediaGetDuration (Handle, ex);
+                Raise ();
+                return duration;
+            }
+        }
+
+        /**
+         * Whether the media was "preparsed". If true, the meta-infos were
+         * extracted, even before the media was played. This is normally only
+         * available if the input files is stored on a local filesystem.
+         */
+        public bool IsPreparsed
+        {
+            get
+            {
+                int preparsed = LibVLC.MediaIsPreparsed (Handle, ex);
+                Raise ();
+                return preparsed != 0;
+            }
+        }
     };
 };