PageRenderTime 82ms CodeModel.GetById 40ms app.highlight 2ms RepoModel.GetById 38ms app.codeStats 0ms

/Multimedia/Vlc/LibVlc/VlcMedia.cs

#
C# | 66 lines | 43 code | 5 blank | 18 comment | 2 complexity | ebd375ea89e3464caf6654e46376a098 MD5 | raw file
 1using System;
 2
 3namespace Delta.Multimedia.Vlc.LibVlc
 4{
 5	internal class VlcMedia : IDisposable
 6	{
 7		#region Handle (Public)
 8		/// <summary>
 9		/// The handle of the media data.
10		/// </summary>
11		public IntPtr Handle
12		{
13			get;
14			private set;
15		}
16		#endregion
17
18		#region State (Public)
19		/// <summary>
20		/// The current state of the media.
21		/// </summary>
22		public VlcMediaState State
23		{
24			get
25			{
26				return VlcCore.libvlc_media_get_state(Handle);
27			}
28		}
29		#endregion
30
31		#region Constructors
32		/// <summary>
33		/// Create a new vlc media instance.
34		/// </summary>
35		/// <param name="instance">The manager instance.</param>
36		/// <param name="filepath">The path to the file.</param>
37		public VlcMedia(VlcInstance instance, string filepath)
38		{
39			Handle = VlcCore.libvlc_media_new_location(instance.Handle, filepath);
40			if (Handle == IntPtr.Zero)
41			{
42				throw new VlcException();
43			}
44		}
45
46		/// <summary>
47		/// Helper constructor to create a wrapper instance from a handle.
48		/// </summary>
49		/// <param name="setHandle">The handle of the media.</param>
50		public VlcMedia(IntPtr setHandle)
51		{
52			Handle = setHandle;
53		}
54		#endregion
55
56		#region IDisposable Members
57		/// <summary>
58		/// Unload the media handle.
59		/// </summary>
60		public void Dispose()
61		{
62			VlcCore.libvlc_media_release(Handle);
63		}
64		#endregion
65	}
66}