PageRenderTime 43ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/Multimedia/Vlc/LibVlc/VlcMedia.cs

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