[vlc-devel] commit: Extend Media class ( Rémi Denis-Courmont )

git version control git at videolan.org
Sat Feb 21 17:15:15 CET 2009


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Sat Feb 21 17:10:02 2009 +0200| [1f4b06d66bd0fc8e2bfeeaf8c77fd88802fe1025] | committer: Rémi Denis-Courmont 

Extend Media class

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1f4b06d66bd0fc8e2bfeeaf8c77fd88802fe1025
---

 bindings/cil/src/libvlc.cs |    2 +-
 bindings/cil/src/media.cs  |   58 +++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 58 insertions(+), 2 deletions(-)

diff --git a/bindings/cil/src/libvlc.cs b/bindings/cil/src/libvlc.cs
index 1728cc9..157a32b 100644
--- a/bindings/cil/src/libvlc.cs
+++ b/bindings/cil/src/libvlc.cs
@@ -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);*/
diff --git a/bindings/cil/src/media.cs b/bindings/cil/src/media.cs
index 3a001b4..18d6b78 100644
--- a/bindings/cil/src/media.cs
+++ b/bindings/cil/src/media.cs
@@ -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;
+            }
+        }
     };
 };




More information about the vlc-devel mailing list