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 #pragma warning disable CS0618 // Type or member is obsolete
30 internal MediaInfo(Interop.MediaInfoHandle handle)
32 Id = InteropHelper.GetString(handle, Interop.MediaInfo.GetMediaId);
34 Path = InteropHelper.GetString(handle, Interop.MediaInfo.GetFilePath);
35 DisplayName = InteropHelper.GetString(handle, Interop.MediaInfo.GetDisplayName);
37 MediaType = InteropHelper.GetValue<MediaType>(handle, Interop.MediaInfo.GetMediaType);
39 MimeType = InteropHelper.GetString(handle, Interop.MediaInfo.GetMimeType);
41 FileSize = InteropHelper.GetValue<long>(handle, Interop.MediaInfo.GetSize);
43 DateAdded = InteropHelper.GetDateTime(handle, Interop.MediaInfo.GetAddedTime);
44 DateModified = InteropHelper.GetDateTime(handle, Interop.MediaInfo.GetModifiedTime);
45 Timeline = InteropHelper.GetDateTime(handle, Interop.MediaInfo.GetTimeline);
47 ThumbnailPath = InteropHelper.GetString(handle, Interop.MediaInfo.GetThumbnailPath, true);
48 Description = InteropHelper.GetString(handle, Interop.MediaInfo.GetDescription);
50 Longitude = InteropHelper.GetValue<double>(handle, Interop.MediaInfo.GetLongitude);
51 Latitude = InteropHelper.GetValue<double>(handle, Interop.MediaInfo.GetLatitude);
52 Altitude = InteropHelper.GetValue<double>(handle, Interop.MediaInfo.GetAltitude);
54 Rating = InteropHelper.GetValue<int>(handle, Interop.MediaInfo.GetRating);
55 IsFavorite = InteropHelper.GetValue<bool>(handle, Interop.MediaInfo.GetFavorite);
56 Title = InteropHelper.GetString(handle, Interop.MediaInfo.GetTitle);
57 StorageId = InteropHelper.GetString(handle, Interop.MediaInfo.GetStorageId);
58 IsDrm = InteropHelper.GetValue<bool>(handle, Interop.MediaInfo.IsDrm);
60 StorageType = InteropHelper.GetValue<StorageType>(handle, Interop.MediaInfo.GetStorageType);
62 #pragma warning restore CS0618 // Type or member is obsolete
65 /// Gets the ID of media.
67 /// <value>The unique ID of media.</value>
68 /// <since_tizen> 4 </since_tizen>
69 public string Id { get; }
72 /// Gets the path to media.
74 /// <value>The full path of the media file.</value>
75 /// <since_tizen> 4 </since_tizen>
76 public string Path { get; }
79 /// Gets the name of media.
81 /// <value>The base name of the media file.</value>
82 /// <since_tizen> 4 </since_tizen>
83 public string DisplayName { get; }
86 /// Gets the <see cref="MediaContent.MediaType"/> of media.
88 /// <value>The <see cref="MediaContent.MediaType"/> of media.</value>
89 /// <since_tizen> 4 </since_tizen>
90 public MediaType MediaType { get; }
93 /// Gets the mime type from media.
95 /// <value>The mime type of media.</value>
96 /// <since_tizen> 4 </since_tizen>
97 public string MimeType { get; }
100 /// Gets the file size of media in bytes.
102 /// <value>The file size of media in bytes.</value>
103 /// <since_tizen> 4 </since_tizen>
104 public long FileSize { get; }
107 /// Gets the date of addition of media.
109 /// <value>The date of addition of media.</value>
110 /// <since_tizen> 4 </since_tizen>
111 public DateTimeOffset DateAdded { get; }
114 /// Gets the date of modification of media.
116 /// <value>The date of modification of media.</value>
117 /// <since_tizen> 4 </since_tizen>
118 public DateTimeOffset DateModified { get; }
121 /// Gets the timeline of media.
124 /// The creation date if the file has the creation information (like recorded date or image creation date),
125 /// otherwise the modified date.
127 /// <since_tizen> 4 </since_tizen>
128 public DateTimeOffset Timeline { get; }
131 /// Gets the thumbnail of media.
133 /// <value>The thumbnail path of media.</value>
134 /// <since_tizen> 4 </since_tizen>
135 public string ThumbnailPath { get; }
138 /// Gets the description of media.
140 /// <value>The description from the metadata.</value>
141 /// <since_tizen> 4 </since_tizen>
142 public string Description { get; }
145 /// Gets the longitude of media.
147 /// <value>The longitude.</value>
148 /// <since_tizen> 4 </since_tizen>
149 public double Longitude { get; }
152 /// Gets the latitude of media.
154 /// <value>The latitude.</value>
155 /// <since_tizen> 4 </since_tizen>
156 public double Latitude { get; }
159 /// Gets the altitude of media.
161 /// <value>The altitude.</value>
162 /// <since_tizen> 4 </since_tizen>
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 public int Rating { get; }
173 /// Gets the favorite status of media.
175 /// <value>true if media is set as favorite, otherwise false.</value>
176 /// <since_tizen> 4 </since_tizen>
177 public bool IsFavorite { get; }
180 /// Gets the title of media.
182 /// <value>The title of media.</value>
183 /// <since_tizen> 4 </since_tizen>
184 public string Title { get; }
187 /// Gets the storage ID of the storage that the media is stored on.
189 /// <value>The storage ID of the storage that the media is stored on.</value>
190 /// <since_tizen> 4 </since_tizen>
191 [Obsolete("Please do not use! this will be deprecated in level 6")]
192 public string StorageId { get; }
195 /// Gets the value indicating whether the media is DRM-protected.
197 /// <value>A bool value indicating whether the media is DRM-protected.</value>
198 /// <since_tizen> 4 </since_tizen>
199 public bool IsDrm { get; }
202 /// Gets the storage type of the storage that the media is stored on.
204 /// <value>The storage type of the storage that the media is stored on.</value>
205 /// <since_tizen> 4 </since_tizen>
206 [Obsolete("Please do not use! this will be deprecated in level 6")]
207 public StorageType StorageType { get; }
210 /// Returns a string representation of the media information.
212 /// <returns>A string representation of the current media information.</returns>
213 /// <since_tizen> 4 </since_tizen>
214 public override string ToString() => $"Id={Id}, Path={Path}, MediaType={MediaType}";
216 internal static MediaInfo FromHandle(Interop.MediaInfoHandle handle)
218 if (handle == null || handle.IsInvalid)
223 var type = InteropHelper.GetValue<MediaType>(handle, Interop.MediaInfo.GetMediaType);
227 case MediaType.Image:
228 return new ImageInfo(handle);
230 case MediaType.Music:
231 case MediaType.Sound:
232 return new AudioInfo(handle);
234 case MediaType.Video:
235 return new VideoInfo(handle);
238 return new BookInfo(handle);
241 return new MediaInfo(handle);
244 internal static MediaInfo FromHandle(IntPtr handle)
246 var safeHandle = new Interop.MediaInfoHandle(handle);
249 return FromHandle(safeHandle);
253 safeHandle.SetHandleAsInvalid();