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); // Deprecated since API12
46 ThumbnailPath = InteropHelper.GetString(handle, Interop.MediaInfo.GetThumbnailPath, true);
47 Description = InteropHelper.GetString(handle, Interop.MediaInfo.GetDescription); // Deprecated since API12
49 Longitude = InteropHelper.GetValue<double>(handle, Interop.MediaInfo.GetLongitude); // Deprecated since API12
50 Latitude = InteropHelper.GetValue<double>(handle, Interop.MediaInfo.GetLatitude); // Deprecated since API12
51 Altitude = InteropHelper.GetValue<double>(handle, Interop.MediaInfo.GetAltitude); // Deprecated since API12
53 Rating = InteropHelper.GetValue<int>(handle, Interop.MediaInfo.GetRating); // Deprecated since API12
54 IsFavorite = InteropHelper.GetValue<bool>(handle, Interop.MediaInfo.GetFavorite); // Deprecated since API12
55 Title = InteropHelper.GetString(handle, Interop.MediaInfo.GetTitle);
56 IsDrm = InteropHelper.GetValue<bool>(handle, Interop.MediaInfo.IsDrm); // Deprecated since API12
60 /// Gets the ID of media.
62 /// <value>The unique ID of media.</value>
63 /// <since_tizen> 4 </since_tizen>
64 public string Id { get; }
67 /// Gets the path to media.
69 /// <value>The full path of the media file.</value>
70 /// <since_tizen> 4 </since_tizen>
71 public string Path { get; }
74 /// Gets the name of media.
76 /// <value>The base name of the media file.</value>
77 /// <since_tizen> 4 </since_tizen>
78 public string DisplayName { get; }
81 /// Gets the <see cref="MediaContent.MediaType"/> of media.
83 /// <value>The <see cref="MediaContent.MediaType"/> of media.</value>
84 /// <since_tizen> 4 </since_tizen>
85 public MediaType MediaType { get; }
88 /// Gets the mime type from media.
90 /// <value>The mime type of media.</value>
91 /// <since_tizen> 4 </since_tizen>
92 public string MimeType { get; }
95 /// Gets the file size of media in bytes.
97 /// <value>The file size of media in bytes.</value>
98 /// <since_tizen> 4 </since_tizen>
99 public long FileSize { get; }
102 /// Gets the date of addition of media.
104 /// <value>The date of addition of media.</value>
105 /// <since_tizen> 4 </since_tizen>
106 public DateTimeOffset DateAdded { get; }
109 /// Gets the date of modification of media.
111 /// <value>The date of modification of media.</value>
112 /// <since_tizen> 4 </since_tizen>
113 public DateTimeOffset DateModified { get; }
116 /// Gets the timeline of media.
119 /// The creation date if the file has the creation information (like recorded date or image creation date),
120 /// otherwise the modified date.
122 /// <since_tizen> 4 </since_tizen>
123 [Obsolete("Deprecated since API12; Will be removed in API14.")]
124 public DateTimeOffset Timeline { get; }
127 /// Gets the thumbnail of media.
129 /// <value>The thumbnail path of media.</value>
130 /// <since_tizen> 4 </since_tizen>
131 public string ThumbnailPath { get; }
134 /// Gets the description of media.
136 /// <value>The description from the metadata.</value>
137 /// <since_tizen> 4 </since_tizen>
138 [Obsolete("Deprecated since API12; Will be removed in API14.")]
139 public string Description { get; }
142 /// Gets the longitude of media.
144 /// <value>The longitude.</value>
145 /// <since_tizen> 4 </since_tizen>
146 [Obsolete("Deprecated since API12; Will be removed in API14.")]
147 public double Longitude { get; }
150 /// Gets the latitude of media.
152 /// <value>The latitude.</value>
153 /// <since_tizen> 4 </since_tizen>
154 [Obsolete("Deprecated since API12; Will be removed in API14.")]
155 public double Latitude { get; }
158 /// Gets the altitude of media.
160 /// <value>The altitude.</value>
161 /// <since_tizen> 4 </since_tizen>
162 [Obsolete("Deprecated since API12; Will be removed in API14.")]
163 public double Altitude { get; }
166 /// Gets the rating of media.
168 /// <value>The rating from the metadata.</value>
169 /// <since_tizen> 4 </since_tizen>
170 [Obsolete("Deprecated since API12; Will be removed in API14.")]
171 public int Rating { get; }
174 /// Gets the favorite status of media.
176 /// <value>true if media is set as favorite, otherwise false.</value>
177 /// <since_tizen> 4 </since_tizen>
178 [Obsolete("Deprecated since API12; Will be removed in API14.")]
179 public bool IsFavorite { get; }
182 /// Gets the title of media.
184 /// <value>The title of media.</value>
185 /// <since_tizen> 4 </since_tizen>
186 public string Title { get; }
189 /// Gets the value indicating whether the media is DRM-protected.
191 /// <value>A bool value indicating whether the media is DRM-protected.</value>
192 /// <since_tizen> 4 </since_tizen>
193 [Obsolete("Deprecated since API12; Will be removed in API14.")]
194 public bool IsDrm { get; }
197 /// Returns a string representation of the media information.
199 /// <returns>A string representation of the current media information.</returns>
200 /// <since_tizen> 4 </since_tizen>
201 public override string ToString() => $"Id={Id}, Path={Path}, MediaType={MediaType}";
203 internal static MediaInfo FromHandle(Interop.MediaInfoHandle handle)
205 if (handle == null || handle.IsInvalid)
210 var type = InteropHelper.GetValue<MediaType>(handle, Interop.MediaInfo.GetMediaType);
214 case MediaType.Image:
215 return new ImageInfo(handle);
217 case MediaType.Music:
218 case MediaType.Sound:
219 return new AudioInfo(handle);
221 case MediaType.Video:
222 return new VideoInfo(handle);
225 return new BookInfo(handle);
228 return new MediaInfo(handle);
231 internal static MediaInfo FromHandle(IntPtr handle)
233 var safeHandle = new Interop.MediaInfoHandle(handle);
236 return FromHandle(safeHandle);
240 safeHandle.SetHandleAsInvalid();