PageRenderTime 89ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/ContentSystem/Multimedia/MusicData.cs

#
C# | 94 lines | 45 code | 8 blank | 41 comment | 0 complexity | 77de1572d1f8b791517047ede7316603 MD5 | raw file
Possible License(s): Apache-2.0
  1. namespace Delta.ContentSystem.Multimedia
  2. {
  3. /// <summary>
  4. /// Abstract base music class for the Delta.Multimedia.Music class. Needs to
  5. /// be implemented in the platform multimedia module (similar to Graphic
  6. /// classes). Unlike many other data classes this does not contain the data
  7. /// yet as it is highly dependant on the native implementation. For example
  8. /// in XNA we actually do not load a wav file, we just keep a native
  9. /// Sound object, while for OpenTK we load the wav data and set it to a
  10. /// stream before releasing it again.
  11. /// </summary>
  12. public class MusicData : Content
  13. {
  14. #region Get (Static)
  15. /// <summary>
  16. /// Get and load content based on the content name. This method makes sure
  17. /// we do not load the same content twice (the constructor is protected).
  18. /// </summary>
  19. /// <param name="contentName">Content name we want to load, this is
  20. /// passed onto the Content System, which will do the actual loading with
  21. /// help of the Load method in this class.</param>
  22. /// <returns>The loaded Content object, always unique for the same
  23. /// name, this helps comparing data.</returns>
  24. public static MusicData Get(string contentName)
  25. {
  26. return Get<MusicData>(contentName, ContentType.Music);
  27. }
  28. #endregion
  29. #region TimeLength (Public)
  30. /// <summary>
  31. /// The length in seconds this music data plays.
  32. /// </summary>
  33. public float TimeLength
  34. {
  35. get
  36. {
  37. return data.TimeLength;
  38. }
  39. }
  40. #endregion
  41. #region Protected
  42. #region MemorySize (Protected)
  43. /// <summary>
  44. /// Change the memory size from the file size to just a small buffer
  45. /// that is used by each native implementation.
  46. /// </summary>
  47. protected override int MemorySize
  48. {
  49. get
  50. {
  51. return 4096;
  52. }
  53. }
  54. #endregion
  55. #endregion
  56. #region Constructors
  57. /// <summary>
  58. /// Create music data
  59. /// </summary>
  60. /// <param name="contentName">Name of the content.</param>
  61. protected MusicData(string contentName)
  62. : base(contentName, ContentType.Music)
  63. {
  64. }
  65. #endregion
  66. #region Methods (Private)
  67. #region Load
  68. /// <summary>
  69. /// Load music 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. }