From 1f4b06d66bd0fc8e2bfeeaf8c77fd88802fe1025 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Sat, 21 Feb 2009 17:10:02 +0200 Subject: [PATCH] Extend Media class --- 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 1728cc95be..157a32b38c 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 3a001b4324..18d6b784b5 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; + } + } }; }; -- 2.39.2