PageRenderTime 72ms CodeModel.GetById 40ms app.highlight 3ms RepoModel.GetById 27ms app.codeStats 1ms

/ContentSystem/Multimedia/VideoData.cs

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