2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 namespace Tizen.Content.MediaContent
23 /// Represents the information related to the media stored.
25 /// <seealso cref="MediaInfoCommand"/>
26 /// <since_tizen> 4 </since_tizen>
27 public class MediaInfo
29 internal MediaInfo(Interop.MediaInfoHandle handle)
31 Id = InteropHelper.GetString(handle, Interop.MediaInfo.GetMediaId);
33 Path = InteropHelper.GetString(handle, Interop.MediaInfo.GetFilePath);
34 DisplayName = InteropHelper.GetString(handle, Interop.MediaInfo.GetDisplayName);
36 MediaType = InteropHelper.GetValue<MediaType>(handle, Interop.MediaInfo.GetMediaType);
38 MimeType = InteropHelper.GetString(handle, Interop.MediaInfo.GetMimeType);
40 FileSize = InteropHelper.GetValue<long>(handle, Interop.MediaInfo.GetSize);
42 DateAdded = InteropHelper.GetDateTime(handle, Interop.MediaInfo.GetAddedTime);
43 DateModified = InteropHelper.GetDateTime(handle, Interop.MediaInfo.GetModifiedTime);
44 Timeline = InteropHelper.GetDateTime(handle, Interop.MediaInfo.GetTimeline);
46 ThumbnailPath = InteropHelper.GetString(handle, Interop.MediaInfo.GetThumbnailPath, true);
47 Description = InteropHelper.GetString(handle, Interop.MediaInfo.GetDescription);
49 Longitude = InteropHelper.GetValue<double>(handle, Interop.MediaInfo.GetLongitude);
50 Latitude = InteropHelper.GetValue<double>(handle, Interop.MediaInfo.GetLatitude);
51 Altitude = InteropHelper.GetValue<double>(handle, Interop.MediaInfo.GetAltitude);
53 Rating = InteropHelper.GetValue<int>(handle, Interop.MediaInfo.GetRating);
54 IsFavorite = InteropHelper.GetValue<bool>(handle, Interop.MediaInfo.GetFavorite);
55 Title = InteropHelper.GetString(handle, Interop.MediaInfo.GetTitle);
56 StorageId = InteropHelper.GetString(handle, Interop.MediaInfo.GetStorageId);
57 IsDrm = InteropHelper.GetValue<bool>(handle, Interop.MediaInfo.IsDrm);
59 StorageType = InteropHelper.GetValue<StorageType>(handle, Interop.MediaInfo.GetStorageType);
63 /// Gets the ID of media.
65 /// <value>The unique ID of media.</value>
66 /// <since_tizen> 4 </since_tizen>
67 public string Id { get; }
70 /// Gets the path to media.
72 /// <value>The full path of the media file.</value>
73 /// <since_tizen> 4 </since_tizen>
74 public string Path { get; }
77 /// Gets the name of media.
79 /// <value>The base name of the media file.</value>
80 /// <since_tizen> 4 </since_tizen>
81 public string DisplayName { get; }
84 /// Gets the <see cref="MediaContent.MediaType"/> of media.
86 /// <value>The <see cref="MediaContent.MediaType"/> of media.</value>
87 /// <since_tizen> 4 </since_tizen>
88 public MediaType MediaType { get; }
91 /// Gets the mime type from media.
93 /// <value>The mime type of media.</value>
94 /// <since_tizen> 4 </since_tizen>
95 public string MimeType { get; }
98 /// Gets the file size of media in bytes.
100 /// <value>The file size of media in bytes.</value>
101 /// <since_tizen> 4 </since_tizen>
102 public long FileSize { get; }
105 /// Gets the date of addition of media.
107 /// <value>The date of addition of media.</value>
108 /// <since_tizen> 4 </since_tizen>
109 public DateTimeOffset DateAdded { get; }
112 /// Gets the date of modification of media.
114 /// <value>The date of modification of media.</value>
115 /// <since_tizen> 4 </since_tizen>
116 public DateTimeOffset DateModified { get; }
119 /// Gets the timeline of media.
122 /// The creation date if the file has the creation information (like recorded date or image creation date),
123 /// otherwise the modified date.
125 /// <since_tizen> 4 </since_tizen>
126 public DateTimeOffset Timeline { get; }
129 /// Gets the thumbnail of media.
131 /// <value>The thumbnail path of media.</value>
132 /// <since_tizen> 4 </since_tizen>
133 public string ThumbnailPath { get; }
136 /// Gets the description of media.
138 /// <value>The description from the metadata.</value>
139 /// <since_tizen> 4 </since_tizen>
140 public string Description { get; }
143 /// Gets the longitude of media.
145 /// <value>The longitude.</value>
146 /// <since_tizen> 4 </since_tizen>
147 public double Longitude { get; }
150 /// Gets the latitude of media.
152 /// <value>The latitude.</value>
153 /// <since_tizen> 4 </since_tizen>
154 public double Latitude { get; }
157 /// Gets the altitude of media.
159 /// <value>The altitude.</value>
160 /// <since_tizen> 4 </since_tizen>
161 public double Altitude { get; }
164 /// Gets the rating of media.
166 /// <value>The rating from the metadata.</value>
167 /// <since_tizen> 4 </since_tizen>
168 public int Rating { get; }
171 /// Gets the favorite status of media.
173 /// <value>true if media is set as favorite, otherwise false.</value>
174 /// <since_tizen> 4 </since_tizen>
175 public bool IsFavorite { get; }
178 /// Gets the title of media.
180 /// <value>The title of media.</value>
181 /// <since_tizen> 4 </since_tizen>
182 public string Title { get; }
185 /// Gets the storage ID of the storage that the media is stored on.
187 /// <value>The storage ID of the storage that the media is stored on.</value>
188 /// <since_tizen> 4 </since_tizen>
189 public string StorageId { get; }
192 /// Gets the value indicating whether the media is DRM-protected.
194 /// <value>A bool value indicating whether the media is DRM-protected.</value>
195 /// <since_tizen> 4 </since_tizen>
196 public bool IsDrm { get; }
199 /// Gets the storage type of the storage that the media is stored on.
201 /// <value>The storage type of the storage that the media is stored on.</value>
202 /// <since_tizen> 4 </since_tizen>
203 public StorageType StorageType { get; }
206 /// Returns a string representation of the media information.
208 /// <returns>A string representation of the current media information.</returns>
209 /// <since_tizen> 4 </since_tizen>
210 public override string ToString() => $"Id={Id}, Path={Path}, MediaType={MediaType}";
212 internal static MediaInfo FromHandle(Interop.MediaInfoHandle handle)
214 if (handle == null || handle.IsInvalid)
219 var type = InteropHelper.GetValue<MediaType>(handle, Interop.MediaInfo.GetMediaType);
223 case MediaType.Image:
224 return new ImageInfo(handle);
226 case MediaType.Music:
227 case MediaType.Sound:
228 return new AudioInfo(handle);
230 case MediaType.Video:
231 return new VideoInfo(handle);
234 return new MediaInfo(handle);
237 internal static MediaInfo FromHandle(IntPtr handle)
239 var safeHandle = new Interop.MediaInfoHandle(handle);
242 return FromHandle(safeHandle);
246 safeHandle.SetHandleAsInvalid();