PageRenderTime 112ms CodeModel.GetById 70ms app.highlight 2ms RepoModel.GetById 38ms app.codeStats 0ms

/ContentSystem/Multimedia/MusicData.cs

#
C# | 94 lines | 45 code | 8 blank | 41 comment | 0 complexity | 77de1572d1f8b791517047ede7316603 MD5 | raw file
 1namespace 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
30		#region TimeLength (Public)
31		/// <summary>
32		/// The length in seconds this music data plays.
33		/// </summary>
34		public float TimeLength
35		{
36			get
37			{
38				return data.TimeLength;
39			}
40		}
41		#endregion
42
43		#region Protected
44
45		#region MemorySize (Protected)
46		/// <summary>
47		/// Change the memory size from the file size to just a small buffer
48		/// that is used by each native implementation.
49		/// </summary>
50		protected override int MemorySize
51		{
52			get
53			{
54				return 4096;
55			}
56		}
57		#endregion
58
59		#endregion
60
61		#region Constructors
62		/// <summary>
63		/// Create music data
64		/// </summary>
65		/// <param name="contentName">Name of the content.</param>
66		protected MusicData(string contentName)
67			: base(contentName, ContentType.Music)
68		{
69		}
70		#endregion
71
72		#region Methods (Private)
73
74		#region Load
75		/// <summary>
76		/// Load music content data, does nothing. Only properties are assigned.
77		/// No loading happens here (it all happens in Sound), we can obviously
78		/// clone all SoundDatas with the same name as they are not loaded here.
79		/// Note: If a class is interested in the content reload functionality,
80		/// it can just attach itself to the ContentChanged event.
81		/// </summary>
82		/// <param name="alreadyLoadedNativeData">If we already have native data
83		/// loaded, clone it from this instance. Only used if not null. Please
84		/// note that this is only used for other objects that had the same
85		/// RawFileId and are already loaded and returned true for this method.
86		/// </param>
87		protected override void Load(Content alreadyLoadedNativeData)
88		{
89		}
90		#endregion
91
92		#endregion
93	}
94}