]> git.sesse.net Git - vlc/blobdiff - bindings/cil/src/media.cs
Extend Media class
[vlc] / bindings / cil / src / media.cs
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;
+            }
+        }
     };
 };