PageRenderTime 40ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/ContentSystem/Multimedia/VideoData.cs

#
C# | 95 lines | 46 code | 9 blank | 40 comment | 0 complexity | 220fb891dc6a5d806a065b64f59d283f MD5 | raw file
Possible License(s): Apache-2.0
  1. using Delta.Engine;
  2. namespace Delta.ContentSystem.Multimedia
  3. {
  4. /// <summary>
  5. /// Video data class, does not contain any native data as this is usually
  6. /// done with some external library or platform module that handles
  7. /// everything from loading to displaying the video for us.
  8. /// </summary>
  9. public class VideoData : Content
  10. {
  11. #region Get (Static)
  12. /// <summary>
  13. /// Get and load content based on the content name. This method makes sure
  14. /// we do not load the same content twice (the constructor is protected).
  15. /// </summary>
  16. /// <param name="contentName">Content name we want to load, this is
  17. /// passed onto the Content System, which will do the actual loading with
  18. /// help of the Load method in this class.</param>
  19. /// <returns>The loaded Content object, always unique for the same
  20. /// name, this helps comparing data.</returns>
  21. public static VideoData Get(string contentName)
  22. {
  23. return Get<VideoData>(contentName, ContentType.Video);
  24. }
  25. #endregion
  26. #region TimeLength (Public)
  27. /// <summary>
  28. /// The length in seconds this video data plays.
  29. /// </summary>
  30. public float TimeLength
  31. {
  32. get
  33. {
  34. return data.TimeLength;
  35. }
  36. }
  37. #endregion
  38. #region Protected
  39. #region MemorySize (Protected)
  40. /// <summary>
  41. /// Change the memory size from the file size to just a small buffer
  42. /// that is used by each native implementation.
  43. /// </summary>
  44. protected override int MemorySize
  45. {
  46. get
  47. {
  48. // We probably need at least 2 textures worth of data (times 4 for
  49. // RGBA), but instead of multiplying by 8 we can assume a compression
  50. // with about 1:8 is used (e.g. DXT1, PVR4Bpp, etc.).
  51. return (int)(Settings.Resolution.Width * Settings.Resolution.Height);
  52. }
  53. }
  54. #endregion
  55. #endregion
  56. #region Constructors
  57. /// <summary>
  58. /// Create base video
  59. /// </summary>
  60. /// <param name="contentName">Name of the content.</param>
  61. public VideoData(string contentName)
  62. : base(contentName, ContentType.Video)
  63. {
  64. }
  65. #endregion
  66. #region Methods (Private)
  67. #region Load
  68. /// <summary>
  69. /// Load video content data, does nothing. Only properties are assigned.
  70. /// No loading happens here (it all happens in Sound), we can obviously
  71. /// clone all SoundDatas with the same name as they are not loaded here.
  72. /// Note: If a class is interested in the content reload functionality,
  73. /// it can just attach itself to the ContentChanged event.
  74. /// </summary>
  75. /// <param name="alreadyLoadedNativeData">If we already have native data
  76. /// loaded, clone it from this instance. Only used if not null. Please
  77. /// note that this is only used for other objects that had the same
  78. /// RawFileId and are already loaded and returned true for this method.
  79. /// </param>
  80. protected override void Load(Content alreadyLoadedNativeData)
  81. {
  82. }
  83. #endregion
  84. #endregion
  85. }
  86. }